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의 구문

관련 정보