⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 information_schema.test

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 TEST
📖 第 1 页 / 共 3 页
字号:
# This test  uses grants, which can't get tested for embedded server-- source include/not_embedded.inc# Test for information_schema.schemata &# show databases--disable_warningsDROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;DROP VIEW IF EXISTS v1;--enable_warningsshow variables where variable_name like "skip_show_database";grant select, update, execute on test.* to mysqltest_2@localhost;grant select, update on test.* to mysqltest_1@localhost;create user mysqltest_3@localhost;create user mysqltest_3;select * from information_schema.SCHEMATA where schema_name > 'm';select schema_name from information_schema.schemata;show databases like 't%';show databases;show databases where `database` = 't%';# Test for information_schema.tables &# show tablescreate database mysqltest;create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));create table test.t2(a int);create table t3(a int, KEY a_data (a));create table mysqltest.t4(a int);create table t5 (id int auto_increment primary key);insert into t5 values (10);create view v1 (c) as select table_name from information_schema.TABLES;select * from v1;select c,table_name from v1 inner join information_schema.TABLES v2 on (v1.c=v2.table_name)where v1.c like "t%";select c,table_name from v1 left join information_schema.TABLES v2 on (v1.c=v2.table_name)where v1.c like "t%";select c, v2.table_name from v1right join information_schema.TABLES v2 on (v1.c=v2.table_name)where v1.c like "t%";select table_name from information_schema.TABLESwhere table_schema = "mysqltest" and table_name like "t%";select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";show keys from t3 where Key_name = "a_data";show tables like 't%';--replace_column 8 # 12 # 13 #show table status;show full columns from t3 like "a%";show full columns from mysql.db like "Insert%";show full columns from v1;select * from information_schema.COLUMNS where table_name="t1"and column_name= "a";show columns from mysqltest.t1 where field like "%a%";create view mysqltest.v1 (c) as select a from mysqltest.t1;grant select (a) on mysqltest.t1 to mysqltest_2@localhost;grant select on mysqltest.v1 to mysqltest_3;connect (user3,localhost,mysqltest_2,,);connection user3;select table_name, column_name, privileges from information_schema.columns where table_schema = 'mysqltest' and table_name = 't1';show columns from mysqltest.t1;connect (user4,localhost,mysqltest_3,,mysqltest);connection user4;select table_name, column_name, privileges from information_schema.columnswhere table_schema = 'mysqltest' and table_name = 'v1';connection default;drop view v1, mysqltest.v1;drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;drop database mysqltest;# Test for information_schema.CHARACTER_SETS &# SHOW CHARACTER SETselect * from information_schema.CHARACTER_SETSwhere CHARACTER_SET_NAME like 'latin1%';SHOW CHARACTER SET LIKE 'latin1%';SHOW CHARACTER SET WHERE charset like 'latin1%';# Test for information_schema.COLLATIONS &# SHOW COLLATION--replace_column 5 #select * from information_schema.COLLATIONSwhere COLLATION_NAME like 'latin1%';--replace_column 5 #SHOW COLLATION LIKE 'latin1%';--replace_column 5 #SHOW COLLATION WHERE collation like 'latin1%';select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITYwhere COLLATION_NAME like 'latin1%';# Test for information_schema.ROUTINES &#--disable_warningsdrop procedure if exists sel2;drop function if exists sub1;drop function if exists sub2;--enable_warningscreate function sub1(i int) returns int  return i+1;delimiter |;create procedure sel2()begin  select * from t1;  select * from t2;end|delimiter ;|## Bug#7222 information_schema: errors in "routines"#select parameter_style, sql_data_access, dtd_identifier from information_schema.routines;--replace_column 5 # 6 #show procedure status;--replace_column 5 # 6 #show function status;select a.ROUTINE_NAME from information_schema.ROUTINES a,information_schema.SCHEMATA b wherea.ROUTINE_SCHEMA = b.SCHEMA_NAME;--replace_column 3 #explain select a.ROUTINE_NAME from information_schema.ROUTINES a,information_schema.SCHEMATA b wherea.ROUTINE_SCHEMA = b.SCHEMA_NAME;select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a,mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) order by 1;select count(*) from information_schema.ROUTINES;create view v1 as select routine_schema, routine_name from information_schema.routines order by routine_schema, routine_name;select * from v1;drop view v1;connect (user1,localhost,mysqltest_1,,);connection user1;select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;--error 1305show create function sub1;connection user3;select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;connection default;grant all privileges on test.* to mysqltest_1@localhost;connect (user2,localhost,mysqltest_1,,);connection user2;select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;create function sub2(i int) returns int  return i+1;select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;show create procedure sel2;show create function sub1;show create function sub2;--replace_column 5 # 6 #show function status like "sub2";connection default;disconnect user1;drop function sub2;show create procedure sel2;## Test for views#create view v0 (c) as select schema_name from information_schema.schemata;select * from v0;--replace_column 3 #explain select * from v0;create view v1 (c) as select table_name from information_schema.tableswhere table_name="v1";select * from v1;create view v2 (c) as select column_name from information_schema.columnswhere table_name="v2";select * from v2;create view v3 (c) as select CHARACTER_SET_NAME from information_schema.character_setswhere CHARACTER_SET_NAME like "latin1%";select * from v3;create view v4 (c) as select COLLATION_NAME from information_schema.collationswhere COLLATION_NAME like "latin1%";select * from v4;show keys from v4;select * from information_schema.views where TABLE_NAME like "v%";drop view v0, v1, v2, v3, v4;## Test for privileges tables#create table t1 (a int);grant select,update,insert on t1 to mysqltest_1@localhost;grant select (a), update (a),insert(a), references(a) on t1 to mysqltest_1@localhost;grant all on test.* to mysqltest_1@localhost with grant option;select * from information_schema.USER_PRIVILEGES where grantee like '%mysqltest_1%';select * from information_schema.SCHEMA_PRIVILEGES where grantee like '%mysqltest_1%';select * from information_schema.TABLE_PRIVILEGES where grantee like '%mysqltest_1%';select * from information_schema.COLUMN_PRIVILEGES where grantee like '%mysqltest_1%';delete from mysql.user where user like 'mysqltest%';delete from mysql.db where user like 'mysqltest%';delete from mysql.tables_priv where user like 'mysqltest%';delete from mysql.columns_priv where user like 'mysqltest%';flush privileges;drop table t1;## Test for KEY_COLUMN_USAGE & TABLE_CONSTRAINTS tables#create table t1 (a int null, primary key(a));alter table t1 add constraint constraint_1 unique (a);alter table t1 add constraint unique key_1(a);alter table t1 add constraint constraint_2 unique key_2(a);show create table t1;select * from information_schema.TABLE_CONSTRAINTS whereTABLE_SCHEMA= "test";select * from information_schema.KEY_COLUMN_USAGE whereTABLE_SCHEMA= "test";connection user2;select table_name from information_schema.TABLES where table_schema like "test%";select table_name,column_name from information_schema.COLUMNS where table_schema like "test%";select ROUTINE_NAME from information_schema.ROUTINES;disconnect user2;connection default;delete from mysql.user where user='mysqltest_1';drop table t1;drop procedure sel2;drop function sub1;create table t1(a int);create view v1 (c) as select a from t1 with check option;create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION;create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;select * from information_schema.views;grant select (a) on test.t1 to joe@localhost with grant option;select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES;drop view v1, v2, v3;drop table t1;delete from mysql.user where user='joe';delete from mysql.db where user='joe';delete from mysql.tables_priv where user='joe';delete from mysql.columns_priv where user='joe';flush privileges;# QQ This results in NULLs instead of the version numbers when# QQ a LOCK TABLES is in effect when selecting from# QQ information_schema.tables.--disable_parsing # until bug is fixeddelimiter //;create procedure px5 ()begindeclare v int;declare c cursor for select version frominformation_schema.tables where table_schema <> 'information_schema';open c;fetch c into v;select v;close c;end;//call px5()//call px5()//delimiter ;//select sql_mode from information_schema.ROUTINES;drop procedure px5;--enable_parsingcreate table t1 (a int not null auto_increment,b int, primary key (a));insert into t1 values (1,1),(NULL,3),(NULL,4);select AUTO_INCREMENT from information_schema.tables where table_name = 't1';drop table t1;create table t1 (s1 int);insert into t1 values (0),(9),(0);select s1 from t1 where s1 in (select version frominformation_schema.tables) union select version frominformation_schema.tables;drop table t1;SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;set names latin2;SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;set names latin1;create table t1 select * from information_schema.CHARACTER_SETSwhere CHARACTER_SET_NAME like "latin1";select * from t1;alter table t1 default character set utf8;show create table t1;drop table t1;create view v1 as select * from information_schema.TABLES;drop view v1;create table t1(a NUMERIC(5,3), b NUMERIC(5,1), c float(5,2), d NUMERIC(6,4), e float, f DECIMAL(6,3), g int(11), h DOUBLE(10,3), i DOUBLE);select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,  CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALEfrom information_schema.columns where table_name= 't1';drop table t1;create table t115 as select table_name, column_name, column_typefrom information_schema.columns where table_name = 'proc';select * from t115;drop table t115;delimiter //;create procedure p108 () begin declare c cursor for select data_typefrom information_schema.columns;  open c; open c; end;//--error 1325call p108()//delimiter ;//drop procedure p108;create view v1 as select A1.table_name from information_schema.TABLES A1where table_name= "user";select * from v1;drop view v1;create view vo as select 'a' union select 'a';  show index from vo;select * from information_schema.TABLE_CONSTRAINTS whereTABLE_NAME= "vo";select * from information_schema.KEY_COLUMN_USAGE whereTABLE_NAME= "vo"; drop view vo;select TABLE_NAME,TABLE_TYPE,ENGINEfrom information_schema.tables where table_schema='information_schema' limit 2;show tables from information_schema like "T%";--error 1044create database information_schema;use information_schema;show full tables like "T%";--error 1109create table t1(a int);use test;show tables;use information_schema;show tables like "T%";## Bug#7210: information_schema: can't access when table-name = reserved word#select table_name from tables where table_name='user';select column_name, privileges from columnswhere table_name='user' and column_name like '%o%';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -