2014-12-10 10:41:14 +01:00
|
|
|
#
|
|
|
|
# MDEV-7285 SERVER: CREATE OR REPLACE and CREATE IF NOT EXISTS
|
|
|
|
#
|
|
|
|
CREATE SERVER IF NOT EXISTS server1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'user1', HOST 'localhost', DATABASE 'test0');
|
|
|
|
SELECT server_name, username, db FROM mysql.servers;
|
|
|
|
server_name username db
|
|
|
|
server1 user1 test0
|
|
|
|
CREATE SERVER IF NOT EXISTS server1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'user2', HOST 'localhost', DATABASE 'test1');
|
|
|
|
Warnings:
|
2022-05-10 06:08:33 +02:00
|
|
|
Note 1476 Cannot create foreign server 'server1' as it already exists
|
2014-12-10 10:41:14 +01:00
|
|
|
SELECT server_name, username, db FROM mysql.servers;
|
|
|
|
server_name username db
|
|
|
|
server1 user1 test0
|
|
|
|
CREATE OR REPLACE SERVER server1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'user3', HOST 'localhost', DATABASE 'test2');
|
|
|
|
SELECT server_name, username, db FROM mysql.servers;
|
|
|
|
server_name username db
|
|
|
|
server1 user3 test2
|
|
|
|
DROP SERVER IF EXISTS server1;
|
|
|
|
SELECT server_name, username, db FROM mysql.servers;
|
|
|
|
server_name username db
|
|
|
|
DROP SERVER IF EXISTS server1;
|
|
|
|
CREATE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test0');
|
|
|
|
CREATE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test1');
|
2022-05-10 06:08:33 +02:00
|
|
|
ERROR HY000: Cannot create foreign server 'server_1' as it already exists
|
2014-12-10 10:41:14 +01:00
|
|
|
CREATE SERVER IF NOT EXISTS server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test2');
|
|
|
|
Warnings:
|
2022-05-10 06:08:33 +02:00
|
|
|
Note 1476 Cannot create foreign server 'server_1' as it already exists
|
2014-12-10 10:41:14 +01:00
|
|
|
SELECT server_name, username, db FROM mysql.servers;
|
|
|
|
server_name username db
|
|
|
|
server_1 mysqltest_1 test0
|
|
|
|
CREATE OR REPLACE SERVER IF NOT EXISTS server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test3');
|
|
|
|
ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS
|
|
|
|
CREATE OR REPLACE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test4');
|
|
|
|
SELECT server_name, username, db FROM mysql.servers;
|
|
|
|
server_name username db
|
|
|
|
server_1 mysqltest_1 test4
|
|
|
|
DROP SERVER server_1;
|
2016-10-09 01:20:17 +02:00
|
|
|
CREATE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'Remote', HOST 'Server.Example.Com', DATABASE 'test');
|
|
|
|
SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1';
|
|
|
|
Host
|
2019-06-18 15:58:41 +02:00
|
|
|
Server.Example.Com
|
2016-10-09 01:20:17 +02:00
|
|
|
ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org');
|
|
|
|
SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1';
|
|
|
|
Host
|
2019-06-18 15:58:41 +02:00
|
|
|
Server.Example.Org
|
2016-10-09 01:20:17 +02:00
|
|
|
DROP SERVER server_1;
|