MySql 同义词删除和创建

MySql 同义词删除和创建

我遇到一个问题,当我的脚本运行时,它的 MySql 部分不起作用或正在删除同义词。我还需要在命令中添加其他内容才能让它登录到 MySql 服务器并执行所述的所有操作吗?

#! /bin/bash

#Subject: Please stage the following TFL09143 Locator Bulletin to all TF90 staging environments:#



#########################################################################
# This next section is to go to mysql server and make changes.          #
# you can drop and create synonyms                                      #
# truncate a table and insert into a different one.                     #
# you will be able to verify the counts to the different locations      #
#########################################################################

$ mysql -h=app03-bsi -u "" -p ""  "TF90BPS" -bse "drop_view TF90.BTXADDR drop_view TF90.BTXSUPB CREATE_VIEW TF90.BTXADDR FOR TF90BP.TFBPS2.BTXADDR CREATE_VIEW TF90.BTXSUPB FOR TF90BP.TFBPS3.BTXSUPB TRUNCATE TABLE TF90BP.TFBPS3.BTXSUPB SELECT (*) FROM TF90BP.TFBPS2.BTXSUPB; select count (*) from TF90BP.TF90.BTXADDR select count(*) from TF90BPS.TF90.BTXADDR; select count(*) from TF90BP.TF90.BTXSUPB; select count(*) from TF90BPS.TF90.BTXSUPB;"

$ mysql -h=app03-bsi -u "" -p ""  "TF90LMS" -bse "drop_view TF90.BTXADDR drop_view TF90.BTXSUPB CREATE_VIEW TF90.BTXADDR FOR TF90LM.TFBPS2.BTXADDR CREATE_VIEW TF90.BTXSUPB FOR TF90LM.TFBPS3.BTXSUPB; TRUNCATE TABLE TF90LM.TFLMS2.BTXADDR;TRUNCATE TABLE TF90LM.TFLMS3.BTXSUPB;INSERT INTO TF90LM.TFLMS3.BTXSUPB SELECT * FROM TF90LM.TFLMS2.BTXSUPB;Verify select count(*) from TF90LM.TF90.BTXADDR;select count(*) from TF90LMS.TF90.BTXADDR;select count(*) from TF90LM.TF90.BTXSUPB;select count(*) from TF90LMS.TF90.BTXSUPB"

$ mysql -h=app03-bsi -u "" -p ""  "TF90NCS" -bse "drop_view TF90.BTXADDR  drop_view TF90.BTXSUPB CREATE_VIEW TF90.BTXADDR FOR TF90NC.TFBPS2.BTXADDR CREATE_VIEW TF90.BTXSUPB FOR TF90NC.TFBPS3.BTXSUPB; TRUNCATE TABLE TF90NC.TFNCS2.BTXADDR; TRUNCATE TABLE TF90NC.TFNCS3.BTXSUPB; INSERT INTO TF90NC.TFNCS3.BTXSUPB SELECT * FROM TF90NC.TFNCS2.BTXSUPB; Verify select count(*) from TF90NC.TF90.BTXADDR; select count(*) from TF90NCS.TF90.BTXADDR;select count(*) from TF90NC.TF90.BTXSUPB;select count(*) from TF90NCS.TF90.BTXSUPB"

$ mysql -h=app03-bsi -u "" -p ""  "TF90PVS" -bse "drop_view TF90.BTXADDR drop_view TF90.BTXSUPB CREATE_VIEW TF90.BTXADDR FOR TF90PV.TFBPS2.BTXADDR CREATE_VIEW TF90.BTXSUPB FOR TF90PV.TFBPS3.BTXSUPB; TRUNCATE TABLE TF90PV.TFPVS2.BTXADDR;TRUNCATE TABLE TF90PV.TFPVS3.BTXSUPB;INSERT INTO TF90PV.TFPVS3.BTXSUPB SELECT * FROM TF90PV.TFPVS2.BTXSUPB;Verify select count(*) from TF90PV.TF90.BTXADDR;select count(*) from TF90PVS.TF90.BTXADDR;select count(*) from TF90PV.TF90.BTXSUPB;select count(*) from TF90PVS.TF90.BTXSUPB"

#TFL09143 Staging#

cd \\ntsrv\common\To\IT-CERT-TEST\TFL09143 #change to mapped network drive 

cp -p TFL09143.pkg /d:/tf90/code_stg /tf90bp/code_stg /tf90lm/code_stg /tf90pv/code_stg 

InvalidInput="true" 

if [ $# -eq 0 ] ; then
    echo "This script sets up TF90 Staging"
    echo -n "Which production do you want to run? (RB/TaxLocator/Cyclic)"
    read ProductionDistro
else
    ProductionDistro="$1"
fi

while [ "$InvalidInput" = "true" ]
do
    if [ "$ProductionDistro" = "RB" -o "$ProductionDistro" = "TaxLocator" -o "$ProductionDistro" = "Cyclic" ] ; then
                    InvalidInput="false"
        break
    else 
        echo "You have entered an error"
        echo "You must type RB or TaxLocator or Cyclic"
        echo "you typed $ProductionDistro"
        echo "This script sets up TF90 Staging"
        read ProductionDistro
    fi
done

InvalidInput="true"

if [ $# -eq 0 ] ; then
    echo "This script sets up RB TF90 Staging"
    echo -n "Which Element do you want to run? (TF90/TF90BP/TF90LM/TF90PV/ALL)"
    read ElementDistro
else
    ElementDistro="$1"
fi

    while [ "$InvalidInput" = "true" ]
do
    if [ "$ElementDistro" = "TF90" -o "$ElementDistro" = "TF90BP" -o "$ElementDistro" = "TF90LM" -o "$ElementDistro" = "TF90PV" -o "$ElementDistro" = "ALL" ] ; then
        InvalidInput="false"
        break
    else 
        echo "You have entered an error"
        echo "You must type TF90 or TF90BP or TF90LM or TF90PV"
        echo "you typed $ElementDistro"
        echo "This script sets up TF90 Staging"
        read ElementDistro
    fi


done 

if [ "$ElementDistro" = "TF90" ] ; then

    cd /d/tf90/code_stg
    vim TFL09143.pkg
    export var=TF90_CONNECT_STRING=DSN=TF90NCS;export Description=TF90NCS;export Trusted_Connection=Yes;export WSID=APP03-
    BSI;export DATABASE=TF90NCS;
    export DATASET=DEFAULT
    yum install -y ../TFL09143.pkg
fi

if [ "$ElementDistro" = "$TF90BP" ] ; then
    cd /d/tf90bp/code_stg
    vim TFL09143.pkg
    export TF90_CONNECT_STRING=DSN=TF90BPS;export Description=TF90BPS;export Trusted_Connection=Yes;export WSID=APP03-
    BSI;export DATABASE=TF90BPS;
    yum install -y ../TFL09143.pkg
fi

if [ "$ElementDistro" = "$TF90LM" ] ; then
    cd /d/tf90lm/code_stg
    vim TFL09143.pkg 
    export TF90_CONNECT_STRING=DSN=TF90LMS;export Description=TF90LMS;export Trusted_Connection=Yes;export WSID=APP03-
    BSI;export DATABASE=TF90LMS;
    yum install -y ../TFL09143.pkg 
fi

if [ "$ElementDistro" = "TF90PV" ] ; then
    cd /d/tf90pv/code_stg
    vim TFL09143.pkg
    export TF90_CONNECT_STRING=DSN=TF90PVS;Description=TF90PVS;Trusted_Connection=Yes;WSID=APP03-
    BSI;DATABASE=TF90PVS;
    yum install -y ../TFL09143.pkg
fi

exit 0

答案1

我认为这里的主要问题是 MySQL 不支持同义词。那是甲骨文的事情。

mysql> CREATE SYNONYM info2 FOR info;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SYNONYM info2 FOR info' at line 1

这是关于如何模仿这种行为的一个很好的链接(http://blog.mclaughlinsoftware.com/2013/11/24/mysql-synonym/)它使用创建视图来自 MySQL 的语法

相关内容