1 DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
2 DROP VIEW IF EXISTS v1;
3 show variables where variable_name like "skip_show_database";
6 grant select, update, execute on test.* to mysqltest_2@localhost;
7 grant select, update on test.* to mysqltest_1@localhost;
8 create user mysqltest_3@localhost;
9 create user mysqltest_3;
10 select * from information_schema.SCHEMATA where schema_name > 'm';
11 CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH
12 NULL mtr latin1 latin1_swedish_ci NULL
13 NULL mysql latin1 latin1_swedish_ci NULL
14 NULL test latin1 latin1_swedish_ci NULL
15 select schema_name from information_schema.schemata;
21 show databases like 't%';
30 show databases where `database` = 't%';
32 create database mysqltest;
33 create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
34 create table test.t2(a int);
35 create table t3(a int, KEY a_data (a));
36 create table mysqltest.t4(a int);
37 create table t5 (id int auto_increment primary key);
38 insert into t5 values (10);
40 SELECT table_name FROM information_schema.TABLES
41 WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND
42 table_name<>'ndb_binlog_index' AND
43 table_name<>'ndb_apply_status';
48 COLLATION_CHARACTER_SET_APPLICABILITY
61 REFERENTIAL_CONSTRAINTS
94 time_zone_transition_type
102 select c,table_name from v1
103 inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
104 where v1.c like "t%";
107 TABLE_CONSTRAINTS TABLE_CONSTRAINTS
108 TABLE_PRIVILEGES TABLE_PRIVILEGES
110 tables_priv tables_priv
112 time_zone_leap_second time_zone_leap_second
113 time_zone_name time_zone_name
114 time_zone_transition time_zone_transition
115 time_zone_transition_type time_zone_transition_type
121 select c,table_name from v1
122 left join information_schema.TABLES v2 on (v1.c=v2.table_name)
123 where v1.c like "t%";
126 TABLE_CONSTRAINTS TABLE_CONSTRAINTS
127 TABLE_PRIVILEGES TABLE_PRIVILEGES
129 tables_priv tables_priv
131 time_zone_leap_second time_zone_leap_second
132 time_zone_name time_zone_name
133 time_zone_transition time_zone_transition
134 time_zone_transition_type time_zone_transition_type
140 select c, v2.table_name from v1
141 right join information_schema.TABLES v2 on (v1.c=v2.table_name)
142 where v1.c like "t%";
145 TABLE_CONSTRAINTS TABLE_CONSTRAINTS
146 TABLE_PRIVILEGES TABLE_PRIVILEGES
148 tables_priv tables_priv
150 time_zone_leap_second time_zone_leap_second
151 time_zone_name time_zone_name
152 time_zone_transition time_zone_transition
153 time_zone_transition_type time_zone_transition_type
159 select table_name from information_schema.TABLES
160 where table_schema = "mysqltest" and table_name like "t%";
164 select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
165 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT
166 NULL mysqltest t1 1 mysqltest string_data 1 b A NULL NULL NULL YES BTREE
167 show keys from t3 where Key_name = "a_data";
168 Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
169 t3 1 a_data 1 a A NULL NULL NULL YES BTREE
170 show tables like 't%';
176 Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
177 t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
178 t3 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
179 t5 MyISAM 10 Fixed 1 7 7 # 2048 0 11 # # NULL latin1_swedish_ci NULL
180 v1 NULL NULL NULL NULL NULL NULL # NULL NULL NULL # # NULL NULL NULL NULL VIEW
181 show full columns from t3 like "a%";
182 Field Type Collation Null Key Default Extra Privileges Comment
183 a int(11) NULL YES MUL NULL select,insert,update,references
184 show full columns from mysql.db like "Insert%";
185 Field Type Collation Null Key Default Extra Privileges Comment
186 Insert_priv enum('N','Y') utf8_general_ci NO N select,insert,update,references
187 show full columns from v1;
188 Field Type Collation Null Key Default Extra Privileges Comment
189 c varchar(64) utf8_general_ci NO select,insert,update,references
190 select * from information_schema.COLUMNS where table_name="t1"
191 and column_name= "a";
192 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
193 NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
194 show columns from mysqltest.t1 where field like "%a%";
195 Field Type Null Key Default Extra
197 create view mysqltest.v1 (c) as select a from mysqltest.t1;
198 grant select (a) on mysqltest.t1 to mysqltest_2@localhost;
199 grant select on mysqltest.v1 to mysqltest_3;
200 select table_name, column_name, privileges from information_schema.columns
201 where table_schema = 'mysqltest' and table_name = 't1';
202 table_name column_name privileges
204 show columns from mysqltest.t1;
205 Field Type Null Key Default Extra
207 select table_name, column_name, privileges from information_schema.columns
208 where table_schema = 'mysqltest' and table_name = 'v1';
209 table_name column_name privileges
211 explain select * from v1;
212 ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
213 drop view v1, mysqltest.v1;
214 drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
215 drop database mysqltest;
216 select * from information_schema.CHARACTER_SETS
217 where CHARACTER_SET_NAME like 'latin1%';
218 CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
219 latin1 latin1_swedish_ci cp1252 West European 1
220 SHOW CHARACTER SET LIKE 'latin1%';
221 Charset Description Default collation Maxlen
222 latin1 cp1252 West European latin1_swedish_ci 1
223 SHOW CHARACTER SET WHERE charset like 'latin1%';
224 Charset Description Default collation Maxlen
225 latin1 cp1252 West European latin1_swedish_ci 1
226 select * from information_schema.COLLATIONS
227 where COLLATION_NAME like 'latin1%';
228 COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
229 latin1_german1_ci latin1 5 # 1
230 latin1_swedish_ci latin1 8 Yes # 1
231 latin1_danish_ci latin1 15 # 1
232 latin1_german2_ci latin1 31 # 2
233 latin1_bin latin1 47 # 1
234 latin1_general_ci latin1 48 # 1
235 latin1_general_cs latin1 49 # 1
236 latin1_spanish_ci latin1 94 # 1
237 SHOW COLLATION LIKE 'latin1%';
238 Collation Charset Id Default Compiled Sortlen
239 latin1_german1_ci latin1 5 # 1
240 latin1_swedish_ci latin1 8 Yes # 1
241 latin1_danish_ci latin1 15 # 1
242 latin1_german2_ci latin1 31 # 2
243 latin1_bin latin1 47 # 1
244 latin1_general_ci latin1 48 # 1
245 latin1_general_cs latin1 49 # 1
246 latin1_spanish_ci latin1 94 # 1
247 SHOW COLLATION WHERE collation like 'latin1%';
248 Collation Charset Id Default Compiled Sortlen
249 latin1_german1_ci latin1 5 # 1
250 latin1_swedish_ci latin1 8 Yes # 1
251 latin1_danish_ci latin1 15 # 1
252 latin1_german2_ci latin1 31 # 2
253 latin1_bin latin1 47 # 1
254 latin1_general_ci latin1 48 # 1
255 latin1_general_cs latin1 49 # 1
256 latin1_spanish_ci latin1 94 # 1
257 select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
258 where COLLATION_NAME like 'latin1%';
259 COLLATION_NAME CHARACTER_SET_NAME
260 latin1_german1_ci latin1
261 latin1_swedish_ci latin1
262 latin1_danish_ci latin1
263 latin1_german2_ci latin1
265 latin1_general_ci latin1
266 latin1_general_cs latin1
267 latin1_spanish_ci latin1
268 drop procedure if exists sel2;
269 drop function if exists sub1;
270 drop function if exists sub2;
271 create function sub1(i int) returns int
273 create procedure sel2()
278 select parameter_style, sql_data_access, dtd_identifier
279 from information_schema.routines where routine_schema='test';
280 parameter_style sql_data_access dtd_identifier
281 SQL CONTAINS SQL NULL
282 SQL CONTAINS SQL int(11)
283 show procedure status where db='test';
284 Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
285 test sel2 PROCEDURE root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
286 show function status where db='test';
287 Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
288 test sub1 FUNCTION root@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
289 select a.ROUTINE_NAME from information_schema.ROUTINES a,
290 information_schema.SCHEMATA b where
291 a.ROUTINE_SCHEMA = b.SCHEMA_NAME AND b.SCHEMA_NAME='test';
295 explain select a.ROUTINE_NAME from information_schema.ROUTINES a,
296 information_schema.SCHEMATA b where
297 a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
298 id select_type table type possible_keys key key_len ref rows Extra
299 1 SIMPLE # ALL NULL NULL NULL NULL NULL
300 1 SIMPLE # ALL NULL NULL NULL NULL NULL Using where; Using join buffer
301 select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a,
302 mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) AND a.ROUTINE_SCHEMA='test' order by 1;
306 select count(*) from information_schema.ROUTINES where routine_schema='test';
309 create view v1 as select routine_schema, routine_name from information_schema.routines where routine_schema='test'
310 order by routine_schema, routine_name;
312 routine_schema routine_name
316 select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
317 ROUTINE_NAME ROUTINE_DEFINITION
318 show create function sub1;
319 ERROR 42000: FUNCTION sub1 does not exist
320 select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
321 ROUTINE_NAME ROUTINE_DEFINITION
324 grant all privileges on test.* to mysqltest_1@localhost;
325 select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
326 ROUTINE_NAME ROUTINE_DEFINITION
329 create function sub2(i int) returns int
331 select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
332 ROUTINE_NAME ROUTINE_DEFINITION
336 show create procedure sel2;
337 Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
338 sel2 NULL latin1 latin1_swedish_ci latin1_swedish_ci
339 show create function sub1;
340 Function sql_mode Create Function character_set_client collation_connection Database Collation
341 sub1 NULL latin1 latin1_swedish_ci latin1_swedish_ci
342 show create function sub2;
343 Function sql_mode Create Function character_set_client collation_connection Database Collation
344 sub2 CREATE DEFINER=`mysqltest_1`@`localhost` FUNCTION `sub2`(i int) RETURNS int(11)
345 return i+1 latin1 latin1_swedish_ci latin1_swedish_ci
346 show function status like "sub2";
347 Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
348 test sub2 FUNCTION mysqltest_1@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
350 show create procedure sel2;
351 Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
352 sel2 CREATE DEFINER=`root`@`localhost` PROCEDURE `sel2`()
356 end latin1 latin1_swedish_ci latin1_swedish_ci
357 create view v0 (c) as select schema_name from information_schema.schemata;
364 explain select * from v0;
365 id select_type table type possible_keys key key_len ref rows Extra
366 1 SIMPLE # ALL NULL NULL NULL NULL NULL
367 create view v1 (c) as select table_name from information_schema.tables
368 where table_name="v1";
372 create view v2 (c) as select column_name from information_schema.columns
373 where table_name="v2";
377 create view v3 (c) as select CHARACTER_SET_NAME from information_schema.character_sets
378 where CHARACTER_SET_NAME like "latin1%";
382 create view v4 (c) as select COLLATION_NAME from information_schema.collations
383 where COLLATION_NAME like "latin1%";
395 Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
396 select * from information_schema.views where TABLE_NAME like "v%";
397 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
398 NULL test v0 select `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
399 NULL test v1 select `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = 'v1') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
400 NULL test v2 select `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = 'v2') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
401 NULL test v3 select `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like 'latin1%') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
402 NULL test v4 select `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like 'latin1%') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
403 drop view v0, v1, v2, v3, v4;
404 create table t1 (a int);
405 grant select,update,insert on t1 to mysqltest_1@localhost;
406 grant select (a), update (a),insert(a), references(a) on t1 to mysqltest_1@localhost;
407 grant all on test.* to mysqltest_1@localhost with grant option;
408 select * from information_schema.USER_PRIVILEGES where grantee like '%mysqltest_1%';
409 GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
410 'mysqltest_1'@'localhost' NULL USAGE NO
411 select * from information_schema.SCHEMA_PRIVILEGES where grantee like '%mysqltest_1%';
412 GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
413 'mysqltest_1'@'localhost' NULL test SELECT YES
414 'mysqltest_1'@'localhost' NULL test INSERT YES
415 'mysqltest_1'@'localhost' NULL test UPDATE YES
416 'mysqltest_1'@'localhost' NULL test DELETE YES
417 'mysqltest_1'@'localhost' NULL test CREATE YES
418 'mysqltest_1'@'localhost' NULL test DROP YES
419 'mysqltest_1'@'localhost' NULL test REFERENCES YES
420 'mysqltest_1'@'localhost' NULL test INDEX YES
421 'mysqltest_1'@'localhost' NULL test ALTER YES
422 'mysqltest_1'@'localhost' NULL test CREATE TEMPORARY TABLES YES
423 'mysqltest_1'@'localhost' NULL test LOCK TABLES YES
424 'mysqltest_1'@'localhost' NULL test EXECUTE YES
425 'mysqltest_1'@'localhost' NULL test CREATE VIEW YES
426 'mysqltest_1'@'localhost' NULL test SHOW VIEW YES
427 'mysqltest_1'@'localhost' NULL test CREATE ROUTINE YES
428 'mysqltest_1'@'localhost' NULL test ALTER ROUTINE YES
429 'mysqltest_1'@'localhost' NULL test EVENT YES
430 'mysqltest_1'@'localhost' NULL test TRIGGER YES
431 select * from information_schema.TABLE_PRIVILEGES where grantee like '%mysqltest_1%';
432 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
433 'mysqltest_1'@'localhost' NULL test t1 SELECT NO
434 'mysqltest_1'@'localhost' NULL test t1 INSERT NO
435 'mysqltest_1'@'localhost' NULL test t1 UPDATE NO
436 select * from information_schema.COLUMN_PRIVILEGES where grantee like '%mysqltest_1%';
437 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
438 'mysqltest_1'@'localhost' NULL test t1 a SELECT NO
439 'mysqltest_1'@'localhost' NULL test t1 a INSERT NO
440 'mysqltest_1'@'localhost' NULL test t1 a UPDATE NO
441 'mysqltest_1'@'localhost' NULL test t1 a REFERENCES NO
442 delete from mysql.user where user like 'mysqltest%';
443 delete from mysql.db where user like 'mysqltest%';
444 delete from mysql.tables_priv where user like 'mysqltest%';
445 delete from mysql.columns_priv where user like 'mysqltest%';
448 create table t1 (a int null, primary key(a));
449 alter table t1 add constraint constraint_1 unique (a);
450 alter table t1 add constraint unique key_1(a);
451 alter table t1 add constraint constraint_2 unique key_2(a);
452 show create table t1;
454 t1 CREATE TABLE `t1` (
455 `a` int(11) NOT NULL DEFAULT '0',
457 UNIQUE KEY `constraint_1` (`a`),
458 UNIQUE KEY `key_1` (`a`),
459 UNIQUE KEY `key_2` (`a`)
460 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
461 select * from information_schema.TABLE_CONSTRAINTS where
462 TABLE_SCHEMA= "test";
463 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
464 NULL test PRIMARY test t1 PRIMARY KEY
465 NULL test constraint_1 test t1 UNIQUE
466 NULL test key_1 test t1 UNIQUE
467 NULL test key_2 test t1 UNIQUE
468 select * from information_schema.KEY_COLUMN_USAGE where
469 TABLE_SCHEMA= "test";
470 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
471 NULL test PRIMARY NULL test t1 a 1 NULL NULL NULL NULL
472 NULL test constraint_1 NULL test t1 a 1 NULL NULL NULL NULL
473 NULL test key_1 NULL test t1 a 1 NULL NULL NULL NULL
474 NULL test key_2 NULL test t1 a 1 NULL NULL NULL NULL
475 select table_name from information_schema.TABLES where table_schema like "test%";
478 select table_name,column_name from information_schema.COLUMNS where table_schema like "test%";
479 table_name column_name
481 select ROUTINE_NAME from information_schema.ROUTINES;
485 delete from mysql.user where user='mysqltest_1';
489 create table t1(a int);
490 create view v1 (c) as select a from t1 with check option;
491 create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION;
492 create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;
493 select * from information_schema.views;
494 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
495 NULL test v1 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
496 NULL test v2 select `test`.`t1`.`a` AS `c` from `test`.`t1` LOCAL YES root@localhost DEFINER latin1 latin1_swedish_ci
497 NULL test v3 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
498 grant select (a) on test.t1 to joe@localhost with grant option;
499 select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
500 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
501 'joe'@'localhost' NULL test t1 a SELECT YES
502 select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES;
503 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
504 drop view v1, v2, v3;
506 delete from mysql.user where user='joe';
507 delete from mysql.db where user='joe';
508 delete from mysql.tables_priv where user='joe';
509 delete from mysql.columns_priv where user='joe';
511 create table t1 (a int not null auto_increment,b int, primary key (a));
512 insert into t1 values (1,1),(NULL,3),(NULL,4);
513 select AUTO_INCREMENT from information_schema.tables where table_name = 't1';
517 create table t1 (s1 int);
518 insert into t1 values (0),(9),(0);
519 select s1 from t1 where s1 in (select version from
520 information_schema.tables) union select version from
521 information_schema.tables;
525 SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
527 CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
528 `CHARACTER_SET_NAME` varchar(32) NOT NULL DEFAULT '',
529 `DEFAULT_COLLATE_NAME` varchar(32) NOT NULL DEFAULT '',
530 `DESCRIPTION` varchar(60) NOT NULL DEFAULT '',
531 `MAXLEN` bigint(3) NOT NULL DEFAULT '0'
532 ) ENGINE=MEMORY DEFAULT CHARSET=utf8
534 SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
536 CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
537 `CHARACTER_SET_NAME` varchar(32) NOT NULL DEFAULT '',
538 `DEFAULT_COLLATE_NAME` varchar(32) NOT NULL DEFAULT '',
539 `DESCRIPTION` varchar(60) NOT NULL DEFAULT '',
540 `MAXLEN` bigint(3) NOT NULL DEFAULT '0'
541 ) ENGINE=MEMORY DEFAULT CHARSET=utf8
543 create table t1 select * from information_schema.CHARACTER_SETS
544 where CHARACTER_SET_NAME like "latin1";
546 CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
547 latin1 latin1_swedish_ci cp1252 West European 1
548 alter table t1 default character set utf8;
549 show create table t1;
551 t1 CREATE TABLE `t1` (
552 `CHARACTER_SET_NAME` varchar(32) NOT NULL DEFAULT '',
553 `DEFAULT_COLLATE_NAME` varchar(32) NOT NULL DEFAULT '',
554 `DESCRIPTION` varchar(60) NOT NULL DEFAULT '',
555 `MAXLEN` bigint(3) NOT NULL DEFAULT '0'
556 ) ENGINE=MyISAM DEFAULT CHARSET=utf8
558 create view v1 as select * from information_schema.TABLES;
560 create table t1(a NUMERIC(5,3), b NUMERIC(5,1), c float(5,2),
561 d NUMERIC(6,4), e float, f DECIMAL(6,3), g int(11), h DOUBLE(10,3),
563 select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
564 CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
565 from information_schema.columns where table_name= 't1';
566 COLUMN_NAME COLUMN_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE
567 a decimal(5,3) NULL NULL 5 3
568 b decimal(5,1) NULL NULL 5 1
569 c float(5,2) NULL NULL 5 2
570 d decimal(6,4) NULL NULL 6 4
571 e float NULL NULL 12 NULL
572 f decimal(6,3) NULL NULL 6 3
573 g int(11) NULL NULL 10 0
574 h double(10,3) NULL NULL 10 3
575 i double NULL NULL 22 NULL
577 create table t115 as select table_name, column_name, column_type
578 from information_schema.columns where table_name = 'proc';
580 table_name column_name column_type
583 proc type enum('FUNCTION','PROCEDURE')
584 proc specific_name char(64)
585 proc language enum('SQL')
586 proc sql_data_access enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA')
587 proc is_deterministic enum('YES','NO')
588 proc security_type enum('INVOKER','DEFINER')
590 proc returns longblob
592 proc definer char(77)
593 proc created timestamp
594 proc modified timestamp
595 proc sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH')
596 proc comment char(64)
597 proc character_set_client char(32)
598 proc collation_connection char(32)
599 proc db_collation char(32)
600 proc body_utf8 longblob
602 create procedure p108 () begin declare c cursor for select data_type
603 from information_schema.columns; open c; open c; end;//
605 ERROR 24000: Cursor is already open
607 create view v1 as select A1.table_name from information_schema.TABLES A1
608 where table_name= "user";
613 create view vo as select 'a' union select 'a';
615 Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
616 select * from information_schema.TABLE_CONSTRAINTS where
618 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
619 select * from information_schema.KEY_COLUMN_USAGE where
621 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
623 select TABLE_NAME,TABLE_TYPE,ENGINE
624 from information_schema.tables
625 where table_schema='information_schema' limit 2;
626 TABLE_NAME TABLE_TYPE ENGINE
627 CHARACTER_SETS SYSTEM VIEW MEMORY
628 COLLATIONS SYSTEM VIEW MEMORY
629 show tables from information_schema like "T%";
630 Tables_in_information_schema (T%)
635 create database information_schema;
636 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
637 use information_schema;
638 show full tables like "T%";
639 Tables_in_information_schema (T%) Table_type
641 TABLE_CONSTRAINTS SYSTEM VIEW
642 TABLE_PRIVILEGES SYSTEM VIEW
644 create table t1(a int);
645 ERROR 42S02: Unknown table 't1' in information_schema
649 use information_schema;
650 show tables like "T%";
651 Tables_in_information_schema (T%)
656 select table_name from tables where table_name='user';
659 select column_name, privileges from columns
660 where table_name='user' and column_name like '%o%';
661 column_name privileges
662 Host select,insert,update,references
663 Password select,insert,update,references
664 Drop_priv select,insert,update,references
665 Reload_priv select,insert,update,references
666 Shutdown_priv select,insert,update,references
667 Process_priv select,insert,update,references
668 Show_db_priv select,insert,update,references
669 Lock_tables_priv select,insert,update,references
670 Show_view_priv select,insert,update,references
671 Create_routine_priv select,insert,update,references
672 Alter_routine_priv select,insert,update,references
673 max_questions select,insert,update,references
674 max_connections select,insert,update,references
675 max_user_connections select,insert,update,references
677 create function sub1(i int) returns int
679 create table t1(f1 int);
680 create view v2 (c) as select f1 from t1;
681 create view v3 (c) as select sub1(1);
682 create table t4(f1 int, KEY f1_key (f1));
685 select table_name from information_schema.views
686 where table_schema='test';
690 select table_name from information_schema.views
691 where table_schema='test';
695 select column_name from information_schema.columns
696 where table_schema='test';
700 Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
701 Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
702 select index_name from information_schema.statistics where table_schema='test';
705 select constraint_name from information_schema.table_constraints
706 where table_schema='test';
709 View Create View character_set_client collation_connection
710 v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `test`.`t1`.`f1` AS `c` from `t1` latin1 latin1_swedish_ci
712 Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
713 show create table v3;
714 View Create View character_set_client collation_connection
715 v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `sub1`(1) AS `c` latin1 latin1_swedish_ci
717 Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
721 select * from information_schema.table_names;
722 ERROR 42S02: Unknown table 'table_names' in information_schema
723 select column_type from information_schema.columns
724 where table_schema="information_schema" and table_name="COLUMNS" and
725 (column_name="character_set_name" or column_name="collation_name");
729 select TABLE_ROWS from information_schema.tables where
730 table_schema="information_schema" and table_name="COLUMNS";
733 select table_type from information_schema.tables
734 where table_schema="mysql" and table_name="user";
737 show open tables where `table` like "user";
738 Database Table In_use Name_locked
740 show status where variable_name like "%database%";
743 show variables where variable_name like "skip_show_databas";
745 show global status like "Threads_running";
748 create table t1(f1 int);
749 create table t2(f2 int);
750 create view v1 as select * from t1, t2;
751 set @got_val= (select count(*) from information_schema.columns);
755 CREATE TABLE t_crashme ( f1 BIGINT);
756 CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
757 CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
761 drop table t_crashme;
762 select table_schema,table_name, column_name from
763 information_schema.columns
764 where data_type = 'longtext';
765 table_schema table_name column_name
766 information_schema COLUMNS COLUMN_DEFAULT
767 information_schema COLUMNS COLUMN_TYPE
768 information_schema EVENTS EVENT_DEFINITION
769 information_schema PARTITIONS PARTITION_EXPRESSION
770 information_schema PARTITIONS SUBPARTITION_EXPRESSION
771 information_schema PARTITIONS PARTITION_DESCRIPTION
772 information_schema PLUGINS PLUGIN_DESCRIPTION
773 information_schema PROCESSLIST INFO
774 information_schema ROUTINES ROUTINE_DEFINITION
775 information_schema TRIGGERS ACTION_CONDITION
776 information_schema TRIGGERS ACTION_STATEMENT
777 information_schema VIEWS VIEW_DEFINITION
778 select table_name, column_name, data_type from information_schema.columns
779 where data_type = 'datetime';
780 table_name column_name data_type
781 EVENTS EXECUTE_AT datetime
782 EVENTS STARTS datetime
784 EVENTS CREATED datetime
785 EVENTS LAST_ALTERED datetime
786 EVENTS LAST_EXECUTED datetime
787 FILES CREATION_TIME datetime
788 FILES LAST_UPDATE_TIME datetime
789 FILES LAST_ACCESS_TIME datetime
790 FILES CREATE_TIME datetime
791 FILES UPDATE_TIME datetime
792 FILES CHECK_TIME datetime
793 PARTITIONS CREATE_TIME datetime
794 PARTITIONS UPDATE_TIME datetime
795 PARTITIONS CHECK_TIME datetime
796 ROUTINES CREATED datetime
797 ROUTINES LAST_ALTERED datetime
798 TABLES CREATE_TIME datetime
799 TABLES UPDATE_TIME datetime
800 TABLES CHECK_TIME datetime
801 TRIGGERS CREATED datetime
802 event execute_at datetime
803 event last_executed datetime
804 event starts datetime
806 SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
808 (SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
809 WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
810 AND A.TABLE_NAME = B.TABLE_NAME);
817 x_decimal DECIMAL(5,3),
818 x_numeric NUMERIC(5,3),
821 x_double_precision DOUBLE PRECISION );
822 SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
823 FROM INFORMATION_SCHEMA.COLUMNS
824 WHERE TABLE_NAME= 't1';
825 COLUMN_NAME CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
833 x_double_precision NULL NULL
835 grant select on test.* to mysqltest_4@localhost;
836 SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
837 where COLUMN_NAME='TABLE_NAME';
838 TABLE_NAME COLUMN_NAME PRIVILEGES
839 COLUMNS TABLE_NAME select
840 COLUMN_PRIVILEGES TABLE_NAME select
841 FILES TABLE_NAME select
842 KEY_COLUMN_USAGE TABLE_NAME select
843 PARTITIONS TABLE_NAME select
844 REFERENTIAL_CONSTRAINTS TABLE_NAME select
845 STATISTICS TABLE_NAME select
846 TABLES TABLE_NAME select
847 TABLE_CONSTRAINTS TABLE_NAME select
848 TABLE_PRIVILEGES TABLE_NAME select
849 VIEWS TABLE_NAME select
850 delete from mysql.user where user='mysqltest_4';
851 delete from mysql.db where user='mysqltest_4';
853 SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
854 table_schema count(*)
855 information_schema 28
857 create table t1 (i int, j int);
858 create trigger trg1 before insert on t1 for each row
864 create trigger trg2 before update on t1 for each row
866 if old.i % 2 = 0 then
870 create trigger trg3 after update on t1 for each row
877 Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
882 end BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
884 if old.i % 2 = 0 then
887 end BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
892 end AFTER NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
893 select * from information_schema.triggers where trigger_schema in ('mysql', 'information_schema', 'test', 'mysqltest');
894 TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
895 NULL test trg1 INSERT NULL test t1 0 NULL begin
899 end ROW BEFORE NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
900 NULL test trg2 UPDATE NULL test t1 0 NULL begin
901 if old.i % 2 = 0 then
904 end ROW BEFORE NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
905 NULL test trg3 UPDATE NULL test t1 0 NULL begin
909 end ROW AFTER NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
914 create database mysqltest;
915 create table mysqltest.t1 (f1 int, f2 int);
916 create table mysqltest.t2 (f1 int);
917 grant select (f1) on mysqltest.t1 to user1@localhost;
918 grant select on mysqltest.t2 to user2@localhost;
919 grant select on mysqltest.* to user3@localhost;
920 grant select on *.* to user4@localhost;
921 select * from information_schema.column_privileges order by grantee;
922 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
923 'user1'@'localhost' NULL mysqltest t1 f1 SELECT NO
924 select * from information_schema.table_privileges order by grantee;
925 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
926 select * from information_schema.schema_privileges order by grantee;
927 GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
928 select * from information_schema.user_privileges order by grantee;
929 GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
930 'user1'@'localhost' NULL USAGE NO
932 Grants for user1@localhost
933 GRANT USAGE ON *.* TO 'user1'@'localhost'
934 GRANT SELECT (f1) ON `mysqltest`.`t1` TO 'user1'@'localhost'
935 select * from information_schema.column_privileges order by grantee;
936 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
937 select * from information_schema.table_privileges order by grantee;
938 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
939 'user2'@'localhost' NULL mysqltest t2 SELECT NO
940 select * from information_schema.schema_privileges order by grantee;
941 GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
942 select * from information_schema.user_privileges order by grantee;
943 GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
944 'user2'@'localhost' NULL USAGE NO
946 Grants for user2@localhost
947 GRANT USAGE ON *.* TO 'user2'@'localhost'
948 GRANT SELECT ON `mysqltest`.`t2` TO 'user2'@'localhost'
949 select * from information_schema.column_privileges order by grantee;
950 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
951 select * from information_schema.table_privileges order by grantee;
952 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
953 select * from information_schema.schema_privileges order by grantee;
954 GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
955 'user3'@'localhost' NULL mysqltest SELECT NO
956 select * from information_schema.user_privileges order by grantee;
957 GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
958 'user3'@'localhost' NULL USAGE NO
960 Grants for user3@localhost
961 GRANT USAGE ON *.* TO 'user3'@'localhost'
962 GRANT SELECT ON `mysqltest`.* TO 'user3'@'localhost'
963 select * from information_schema.column_privileges where grantee like '%user%'
965 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
966 'user1'@'localhost' NULL mysqltest t1 f1 SELECT NO
967 select * from information_schema.table_privileges where grantee like '%user%'
969 GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
970 'user2'@'localhost' NULL mysqltest t2 SELECT NO
971 select * from information_schema.schema_privileges where grantee like '%user%'
973 GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
974 'user3'@'localhost' NULL mysqltest SELECT NO
975 select * from information_schema.user_privileges where grantee like '%user%'
977 GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
978 'user1'@'localhost' NULL USAGE NO
979 'user2'@'localhost' NULL USAGE NO
980 'user3'@'localhost' NULL USAGE NO
981 'user4'@'localhost' NULL SELECT NO
983 Grants for user4@localhost
984 GRANT SELECT ON *.* TO 'user4'@'localhost'
985 drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost;
987 drop database mysqltest;
988 drop procedure if exists p1;
989 drop procedure if exists p2;
990 create procedure p1 () modifies sql data set @a = 5;
991 create procedure p2 () set @a = 5;
992 select sql_data_access from information_schema.routines
993 where specific_name like 'p%';
999 show create database information_schema;
1000 Database Create Database
1001 information_schema CREATE DATABASE `information_schema` /*!40100 DEFAULT CHARACTER SET utf8 */
1002 create table t1(f1 LONGBLOB, f2 LONGTEXT);
1003 select column_name,data_type,CHARACTER_OCTET_LENGTH,
1004 CHARACTER_MAXIMUM_LENGTH
1005 from information_schema.columns
1006 where table_name='t1';
1007 column_name data_type CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH
1008 f1 longblob 4294967295 4294967295
1009 f2 longtext 4294967295 4294967295
1011 create table t1(f1 tinyint, f2 SMALLINT, f3 mediumint, f4 int,
1012 f5 BIGINT, f6 BIT, f7 bit(64));
1013 select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
1014 from information_schema.columns
1015 where table_name='t1';
1016 column_name NUMERIC_PRECISION NUMERIC_SCALE
1025 create table t1 (f1 integer);
1026 create trigger tr1 after insert on t1 for each row set @test_var=42;
1027 use information_schema;
1028 select trigger_schema, trigger_name from triggers where
1030 trigger_schema trigger_name
1034 create table t1 (a int not null, b int);
1035 use information_schema;
1036 select column_name, column_default from columns
1037 where table_schema='test' and table_name='t1';
1038 column_name column_default
1042 show columns from t1;
1043 Field Type Null Key Default Extra
1047 CREATE TABLE t1 (a int);
1048 CREATE TABLE t2 (b int);
1049 SHOW TABLE STATUS FROM test
1050 WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
1051 WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
1052 Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
1053 t1 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
1054 t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
1056 create table t1(f1 int);
1057 create view v1 (c) as select f1 from t1;
1061 show fields from test.v1;
1062 Field Type Null Key Default Extra
1066 alter database information_schema;
1067 ERROR 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 '' at line 1
1068 drop database information_schema;
1069 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
1070 drop table information_schema.tables;
1071 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
1072 alter table information_schema.tables;
1073 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
1074 use information_schema;
1075 create temporary table schemata(f1 char(10));
1076 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
1077 CREATE PROCEDURE p1 ()
1079 SELECT 'foo' FROM DUAL;
1081 ERROR 42000: Unknown database 'information_schema'
1082 select ROUTINE_NAME from routines where ROUTINE_SCHEMA='information_schema';
1084 grant all on information_schema.* to 'user1'@'localhost';
1085 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
1086 grant select on information_schema.* to 'user1'@'localhost';
1087 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
1089 create table t1(id int);
1090 insert into t1(id) values (1);
1091 select 1 from (select 1 from test.t1) a;
1094 use information_schema;
1095 select 1 from (select 1 from test.t1) a;
1100 create table t1 (f1 int(11));
1101 create view v1 as select * from t1;
1103 select table_type from information_schema.tables
1104 where table_name="v1";
1108 create temporary table t1(f1 int, index(f1));
1109 show columns from t1;
1110 Field Type Null Key Default Extra
1111 f1 int(11) YES MUL NULL
1113 Field Type Null Key Default Extra
1114 f1 int(11) YES MUL NULL
1115 show indexes from t1;
1116 Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
1117 t1 1 f1 1 f1 A NULL NULL NULL YES BTREE
1119 create table t1(f1 binary(32), f2 varbinary(64));
1120 select character_maximum_length, character_octet_length
1121 from information_schema.columns where table_name='t1';
1122 character_maximum_length character_octet_length
1126 CREATE TABLE t1 (f1 BIGINT, f2 VARCHAR(20), f3 BIGINT);
1127 INSERT INTO t1 SET f1 = 1, f2 = 'Schoenenbourg', f3 = 1;
1128 CREATE FUNCTION func2() RETURNS BIGINT RETURN 1;
1129 CREATE FUNCTION func1() RETURNS BIGINT
1131 RETURN ( SELECT COUNT(*) FROM INFORMATION_SCHEMA.VIEWS);
1133 CREATE VIEW v1 AS SELECT 1 FROM t1
1134 WHERE f3 = (SELECT func2 ());
1140 DROP FUNCTION func1;
1141 DROP FUNCTION func2;
1142 select column_type, group_concat(table_schema, '.', table_name), count(*) as num
1143 from information_schema.columns where
1144 table_schema='information_schema' and
1145 (column_type = 'varchar(7)' or column_type = 'varchar(20)'
1146 or column_type = 'varchar(27)')
1147 group by column_type order by num;
1148 column_type group_concat(table_schema, '.', table_name) num
1149 varchar(27) information_schema.COLUMNS 1
1150 varchar(7) information_schema.ROUTINES,information_schema.VIEWS 2
1151 varchar(20) information_schema.FILES,information_schema.FILES,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PROFILING 6
1152 create table t1(f1 char(1) not null, f2 char(9) not null)
1153 default character set utf8;
1154 select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
1155 information_schema.columns where table_schema='test' and table_name = 't1';
1156 CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
1161 INSERT INTO `proc` VALUES ('test','','PROCEDURE','','SQL','CONTAINS_SQL',
1162 'NO','DEFINER','','','BEGIN\r\n \r\nEND','root@%','2006-03-02 18:40:03',
1163 '2006-03-02 18:40:03','','','utf8','utf8_general_ci','utf8_general_ci','n/a');
1164 select routine_name from information_schema.routines where ROUTINE_SCHEMA='test';
1167 delete from proc where name='';
1169 grant select on test.* to mysqltest_1@localhost;
1170 create table t1 (id int);
1171 create view v1 as select * from t1;
1172 create definer = mysqltest_1@localhost
1173 sql security definer view v2 as select 1;
1174 select * from information_schema.views
1175 where table_name='v1' or table_name='v2';
1176 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
1177 NULL test v1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci
1178 NULL test v2 select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER latin1 latin1_swedish_ci
1181 drop user mysqltest_1@localhost;
1183 create table t1(f1 char(5));
1184 create table t2(f1 char(5));
1185 select concat(@a, table_name), @a, table_name
1186 from information_schema.tables where table_schema = 'test';
1187 concat(@a, table_name) @a table_name
1191 DROP PROCEDURE IF EXISTS p1;
1192 DROP FUNCTION IF EXISTS f1;
1193 CREATE PROCEDURE p1() SET @a= 1;
1194 CREATE FUNCTION f1() RETURNS INT RETURN @a + 1;
1195 CREATE USER mysql_bug20230@localhost;
1196 GRANT EXECUTE ON PROCEDURE p1 TO mysql_bug20230@localhost;
1197 GRANT EXECUTE ON FUNCTION f1 TO mysql_bug20230@localhost;
1198 SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test';
1199 ROUTINE_NAME ROUTINE_DEFINITION
1202 SHOW CREATE PROCEDURE p1;
1203 Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
1204 p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
1205 SET @a= 1 latin1 latin1_swedish_ci latin1_swedish_ci
1206 SHOW CREATE FUNCTION f1;
1207 Function sql_mode Create Function character_set_client collation_connection Database Collation
1208 f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
1209 RETURN @a + 1 latin1 latin1_swedish_ci latin1_swedish_ci
1210 SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test';
1211 ROUTINE_NAME ROUTINE_DEFINITION
1214 SHOW CREATE PROCEDURE p1;
1215 Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
1216 p1 NULL latin1 latin1_swedish_ci latin1_swedish_ci
1217 SHOW CREATE FUNCTION f1;
1218 Function sql_mode Create Function character_set_client collation_connection Database Collation
1219 f1 NULL latin1 latin1_swedish_ci latin1_swedish_ci
1226 DROP USER mysql_bug20230@localhost;
1227 SELECT t.table_name, c1.column_name
1228 FROM information_schema.tables t
1230 information_schema.columns c1
1231 ON t.table_schema = c1.table_schema AND
1232 t.table_name = c1.table_name
1233 WHERE t.table_schema = 'information_schema' AND
1234 c1.ordinal_position =
1235 ( SELECT COALESCE(MIN(c2.ordinal_position),1)
1236 FROM information_schema.columns c2
1237 WHERE c2.table_schema = t.table_schema AND
1238 c2.table_name = t.table_name AND
1239 c2.column_name LIKE '%SCHEMA%'
1241 table_name column_name
1242 CHARACTER_SETS CHARACTER_SET_NAME
1243 COLLATIONS COLLATION_NAME
1244 COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
1245 COLUMNS TABLE_SCHEMA
1246 COLUMN_PRIVILEGES TABLE_SCHEMA
1250 GLOBAL_STATUS VARIABLE_NAME
1251 GLOBAL_VARIABLES VARIABLE_NAME
1252 KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
1253 PARTITIONS TABLE_SCHEMA
1257 REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
1258 ROUTINES ROUTINE_SCHEMA
1259 SCHEMATA SCHEMA_NAME
1260 SCHEMA_PRIVILEGES TABLE_SCHEMA
1261 SESSION_STATUS VARIABLE_NAME
1262 SESSION_VARIABLES VARIABLE_NAME
1263 STATISTICS TABLE_SCHEMA
1265 TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
1266 TABLE_PRIVILEGES TABLE_SCHEMA
1267 TRIGGERS TRIGGER_SCHEMA
1268 USER_PRIVILEGES GRANTEE
1270 SELECT t.table_name, c1.column_name
1271 FROM information_schema.tables t
1273 information_schema.columns c1
1274 ON t.table_schema = c1.table_schema AND
1275 t.table_name = c1.table_name
1276 WHERE t.table_schema = 'information_schema' AND
1277 c1.ordinal_position =
1278 ( SELECT COALESCE(MIN(c2.ordinal_position),1)
1279 FROM information_schema.columns c2
1280 WHERE c2.table_schema = 'information_schema' AND
1281 c2.table_name = t.table_name AND
1282 c2.column_name LIKE '%SCHEMA%'
1284 table_name column_name
1285 CHARACTER_SETS CHARACTER_SET_NAME
1286 COLLATIONS COLLATION_NAME
1287 COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
1288 COLUMNS TABLE_SCHEMA
1289 COLUMN_PRIVILEGES TABLE_SCHEMA
1293 GLOBAL_STATUS VARIABLE_NAME
1294 GLOBAL_VARIABLES VARIABLE_NAME
1295 KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
1296 PARTITIONS TABLE_SCHEMA
1300 REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
1301 ROUTINES ROUTINE_SCHEMA
1302 SCHEMATA SCHEMA_NAME
1303 SCHEMA_PRIVILEGES TABLE_SCHEMA
1304 SESSION_STATUS VARIABLE_NAME
1305 SESSION_VARIABLES VARIABLE_NAME
1306 STATISTICS TABLE_SCHEMA
1308 TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
1309 TABLE_PRIVILEGES TABLE_SCHEMA
1310 TRIGGERS TRIGGER_SCHEMA
1311 USER_PRIVILEGES GRANTEE
1313 SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test');
1316 SELECT table_name from information_schema.tables
1317 WHERE table_name=(SELECT MAX(table_name)
1318 FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'));
1321 DROP TABLE IF EXISTS bug23037;
1322 DROP FUNCTION IF EXISTS get_value;
1323 SELECT COLUMN_NAME, MD5(COLUMN_DEFAULT), LENGTH(COLUMN_DEFAULT) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='bug23037';
1324 COLUMN_NAME MD5(COLUMN_DEFAULT) LENGTH(COLUMN_DEFAULT)
1325 fld1 7cf7a6782be951a1f2464a350da926a5 65532
1326 SELECT MD5(get_value());
1328 7cf7a6782be951a1f2464a350da926a5
1329 SELECT COLUMN_NAME, MD5(COLUMN_DEFAULT), LENGTH(COLUMN_DEFAULT), COLUMN_DEFAULT=get_value() FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='bug23037';
1330 COLUMN_NAME MD5(COLUMN_DEFAULT) LENGTH(COLUMN_DEFAULT) COLUMN_DEFAULT=get_value()
1331 fld1 7cf7a6782be951a1f2464a350da926a5 65532 1
1332 DROP TABLE bug23037;
1333 DROP FUNCTION get_value;
1335 select table_schema as object_schema,
1336 table_name as object_name,
1337 table_type as object_type
1338 from information_schema.tables
1339 order by object_schema;
1340 explain select * from v1;
1341 id select_type table type possible_keys key key_len ref rows Extra
1342 1 SIMPLE tables ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases; Using filesort
1343 explain select * from (select table_name from information_schema.tables) as a;
1344 id select_type table type possible_keys key key_len ref rows Extra
1345 1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
1346 2 DERIVED tables ALL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases
1348 create table t1 (f1 int(11));
1349 create table t2 (f1 int(11), f2 int(11));
1350 select table_name from information_schema.tables
1351 where table_schema = 'test' and table_name not in
1352 (select table_name from information_schema.columns
1353 where table_schema = 'test' and column_name = 'f3');
1358 select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
1359 (select cast(table_name as char) from information_schema.tables
1360 order by table_name limit 1) limit 1;
1363 select t.table_name, group_concat(t.table_schema, '.', t.table_name),
1365 from information_schema.tables t
1366 inner join information_schema.columns c1
1367 on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
1368 where t.table_schema = 'information_schema' and
1369 c1.ordinal_position =
1370 (select isnull(c2.column_type) -
1371 isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
1373 from information_schema.columns c2 where
1374 c2.table_schema='information_schema' and
1375 (c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
1376 group by c2.column_type order by num limit 1)
1377 group by t.table_name order by num1, t.table_name;
1378 table_name group_concat(t.table_schema, '.', t.table_name) num1
1379 CHARACTER_SETS information_schema.CHARACTER_SETS 1
1380 COLLATIONS information_schema.COLLATIONS 1
1381 COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
1382 COLUMNS information_schema.COLUMNS 1
1383 COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
1384 ENGINES information_schema.ENGINES 1
1385 EVENTS information_schema.EVENTS 1
1386 FILES information_schema.FILES 1
1387 GLOBAL_STATUS information_schema.GLOBAL_STATUS 1
1388 GLOBAL_VARIABLES information_schema.GLOBAL_VARIABLES 1
1389 KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
1390 PARTITIONS information_schema.PARTITIONS 1
1391 PLUGINS information_schema.PLUGINS 1
1392 PROCESSLIST information_schema.PROCESSLIST 1
1393 PROFILING information_schema.PROFILING 1
1394 REFERENTIAL_CONSTRAINTS information_schema.REFERENTIAL_CONSTRAINTS 1
1395 ROUTINES information_schema.ROUTINES 1
1396 SCHEMATA information_schema.SCHEMATA 1
1397 SCHEMA_PRIVILEGES information_schema.SCHEMA_PRIVILEGES 1
1398 SESSION_STATUS information_schema.SESSION_STATUS 1
1399 SESSION_VARIABLES information_schema.SESSION_VARIABLES 1
1400 STATISTICS information_schema.STATISTICS 1
1401 TABLES information_schema.TABLES 1
1402 TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
1403 TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
1404 TRIGGERS information_schema.TRIGGERS 1
1405 USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
1406 VIEWS information_schema.VIEWS 1
1407 create table t1(f1 int);
1408 create view v1 as select f1+1 as a from t1;
1409 create table t2 (f1 int, f2 int);
1410 create view v2 as select f1+1 as a, f2 as b from t2;
1411 select table_name, is_updatable from information_schema.views;
1412 table_name is_updatable
1419 ERROR 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 '' at line 1
1420 alter database test;
1421 ERROR 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 '' at line 1
1422 create database mysqltest;
1423 create table mysqltest.t1(a int, b int, c int);
1424 create trigger mysqltest.t1_ai after insert on mysqltest.t1
1425 for each row set @a = new.a + new.b + new.c;
1426 grant select(b) on mysqltest.t1 to mysqltest_1@localhost;
1427 select trigger_name from information_schema.triggers
1428 where event_object_table='t1';
1431 show triggers from mysqltest;
1432 Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
1433 t1_ai INSERT t1 set @a = new.a + new.b + new.c AFTER NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
1434 show columns from t1;
1435 Field Type Null Key Default Extra
1437 select column_name from information_schema.columns where table_name='t1';
1441 Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
1442 select trigger_name from information_schema.triggers
1443 where event_object_table='t1';
1445 drop user mysqltest_1@localhost;
1446 drop database mysqltest;
1449 f2 varchar(50) not null,
1450 f3 varchar(50) default '',
1451 f4 varchar(50) default NULL,
1453 f6 bigint not null default 10,
1454 f7 datetime not null,
1455 f8 datetime default '2006-01-01'
1457 select column_default from information_schema.columns where table_name= 't1';
1467 show columns from t1;
1468 Field Type Null Key Default Extra
1469 f1 varchar(50) YES NULL
1470 f2 varchar(50) NO NULL
1472 f4 varchar(50) YES NULL
1473 f5 bigint(20) NO NULL
1476 f8 datetime YES 2006-01-01 00:00:00
1478 show fields from information_schema.table_names;
1479 ERROR 42S02: Unknown table 'table_names' in information_schema
1480 show keys from information_schema.table_names;
1481 ERROR 42S02: Unknown table 'table_names' in information_schema
1482 USE information_schema;
1483 SET max_heap_table_size = 16384;
1484 CREATE TABLE test.t1( a INT );
1487 JOIN collations co ON ( co.collation_name = ta.table_catalog )
1488 JOIN character_sets cs ON ( cs.character_set_name = ta.table_catalog );
1489 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
1491 SET max_heap_table_size = DEFAULT;
1494 select * from information_schema.engines WHERE ENGINE="MyISAM";
1495 ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
1496 MyISAM DEFAULT Default engine as of MySQL 3.23 with great performance NO NO NO
1497 grant select on *.* to user3148@localhost;
1498 select user,db from information_schema.processlist;
1501 drop user user3148@localhost;
1502 DROP TABLE IF EXISTS server_status;
1503 DROP EVENT IF EXISTS event_status;
1504 SET GLOBAL event_scheduler=1;
1505 CREATE EVENT event_status
1506 ON SCHEDULE AT NOW()
1507 ON COMPLETION NOT PRESERVE
1510 CREATE TABLE server_status
1511 SELECT variable_name
1512 FROM information_schema.global_status
1513 WHERE variable_name LIKE 'ABORTED_CONNECTS' OR
1514 variable_name LIKE 'BINLOG_CACHE_DISK_USE';
1516 SELECT variable_name FROM server_status;
1519 BINLOG_CACHE_DISK_USE
1520 DROP TABLE server_status;
1521 SET GLOBAL event_scheduler=0;
1522 explain select table_name from information_schema.views where
1523 table_schema='test' and table_name='v1';
1524 id select_type table type possible_keys key key_len ref rows Extra
1525 1 SIMPLE views ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Open_frm_only; Scanned 0 databases
1526 explain select * from information_schema.tables;
1527 id select_type table type possible_keys key key_len ref rows Extra
1528 1 SIMPLE tables ALL NULL NULL NULL NULL NULL Open_full_table; Scanned all databases
1529 explain select * from information_schema.collations;
1530 id select_type table type possible_keys key key_len ref rows Extra
1531 1 SIMPLE collations ALL NULL NULL NULL NULL NULL
1532 explain select * from information_schema.tables where
1533 table_schema='test' and table_name= 't1';
1534 id select_type table type possible_keys key key_len ref rows Extra
1535 1 SIMPLE tables ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Open_full_table; Scanned 0 databases
1536 explain select table_name, table_type from information_schema.tables
1537 where table_schema='test';
1538 id select_type table type possible_keys key key_len ref rows Extra
1539 1 SIMPLE tables ALL NULL TABLE_SCHEMA NULL NULL NULL Using where; Open_frm_only; Scanned 1 database
1540 explain select b.table_name
1541 from information_schema.tables a, information_schema.columns b
1542 where a.table_name='t1' and a.table_schema='test' and b.table_name=a.table_name;
1543 id select_type table type possible_keys key key_len ref rows Extra
1544 1 SIMPLE a ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Skip_open_table; Scanned 0 databases
1545 1 SIMPLE b ALL NULL NULL NULL NULL NULL Using where; Open_frm_only; Scanned all databases; Using join buffer
1546 SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
1547 WHERE SCHEMA_NAME = 'mysqltest';
1548 CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH
1549 SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
1550 WHERE SCHEMA_NAME = '';
1551 CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH
1552 SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
1553 WHERE SCHEMA_NAME = 'test';
1554 CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH
1555 NULL test latin1 latin1_swedish_ci NULL
1556 select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME='nonexisting';
1559 select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME='';
1562 select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='';
1565 select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='nonexisting';
1570 FROM information_schema.tables;
1571 SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1';
1573 select `tables`.`TABLE_CATALOG` AS `TABLE_CATALOG`,`tables`.`TABLE_SCHEMA` AS `TABLE_SCHEMA`,`tables`.`TABLE_NAME` AS `TABLE_NAME`,`tables`.`TABLE_TYPE` AS `TABLE_TYPE`,`tables`.`ENGINE` AS `ENGINE`,`tables`.`VERSION` AS `VERSION`,`tables`.`ROW_FORMAT` AS `ROW_FORMAT`,`tables`.`TABLE_ROWS` AS `TABLE_ROWS`,`tables`.`AVG_ROW_LENGTH` AS `AVG_ROW_LENGTH`,`tables`.`DATA_LENGTH` AS `DATA_LENGTH`,`tables`.`MAX_DATA_LENGTH` AS `MAX_DATA_LENGTH`,`tables`.`INDEX_LENGTH` AS `INDEX_LENGTH`,`tables`.`DATA_FREE` AS `DATA_FREE`,`tables`.`AUTO_INCREMENT` AS `AUTO_INCREMENT`,`tables`.`CREATE_TIME` AS `CREATE_TIME`,`tables`.`UPDATE_TIME` AS `UPDATE_TIME`,`tables`.`CHECK_TIME` AS `CHECK_TIME`,`tables`.`TABLE_COLLATION` AS `TABLE_COLLATION`,`tables`.`CHECKSUM` AS `CHECKSUM`,`tables`.`CREATE_OPTIONS` AS `CREATE_OPTIONS`,`tables`.`TABLE_COMMENT` AS `TABLE_COMMENT` from `information_schema`.`tables`
1575 SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
1576 WHERE SCHEMA_NAME ='information_schema';
1579 SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES
1580 WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
1583 select * from information_schema.columns where table_schema = NULL;
1584 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
1585 select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
1586 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
1587 select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
1588 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
1589 select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
1590 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
1591 select * from `information_schema`.`PARTITIONS` where `TABLE_SCHEMA` = NULL;
1592 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
1593 select * from `information_schema`.`PARTITIONS` where `TABLE_NAME` = NULL;
1594 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
1595 select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
1596 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME UNIQUE_CONSTRAINT_CATALOG UNIQUE_CONSTRAINT_SCHEMA UNIQUE_CONSTRAINT_NAME MATCH_OPTION UPDATE_RULE DELETE_RULE TABLE_NAME REFERENCED_TABLE_NAME
1597 select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
1598 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME UNIQUE_CONSTRAINT_CATALOG UNIQUE_CONSTRAINT_SCHEMA UNIQUE_CONSTRAINT_NAME MATCH_OPTION UPDATE_RULE DELETE_RULE TABLE_NAME REFERENCED_TABLE_NAME
1599 select * from information_schema.schemata where schema_name = NULL;
1600 CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH
1601 select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL;
1602 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT
1603 select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL;
1604 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT
1605 select * from information_schema.tables where table_schema = NULL;
1606 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT
1607 select * from information_schema.tables where table_catalog = NULL;
1608 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT
1609 select * from information_schema.tables where table_name = NULL;
1610 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT
1611 select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
1612 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
1613 select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
1614 CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
1615 select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL;
1616 TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
1617 select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL;
1618 TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION
1619 select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL;
1620 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
1621 select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL;
1622 TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
1623 explain extended select 1 from information_schema.tables;
1624 id select_type table type possible_keys key key_len ref rows filtered Extra
1625 1 SIMPLE tables ALL NULL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases
1627 Note 1003 select 1 AS `1` from `information_schema`.`tables`
1628 use information_schema;
1630 Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
1631 show events from information_schema;
1632 Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
1633 show events where Db= 'information_schema';
1634 Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
1637 # Bug#34166 Server crash in SHOW OPEN TABLES and prelocking
1639 drop table if exists t1;
1640 drop function if exists f1;
1641 create table t1 (a int);
1642 create function f1() returns int
1644 insert into t1 (a) values (1);
1647 show open tables where f1()=0;
1648 show open tables where f1()=0;
1651 select * from information_schema.tables where 1=sleep(100000);
1652 select * from information_schema.columns where 1=sleep(100000);
1653 explain select count(*) from information_schema.tables;
1654 id select_type table type possible_keys key key_len ref rows Extra
1655 1 SIMPLE tables ALL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases
1656 explain select count(*) from information_schema.columns;
1657 id select_type table type possible_keys key key_len ref rows Extra
1658 1 SIMPLE columns ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases
1659 explain select count(*) from information_schema.views;
1660 id select_type table type possible_keys key key_len ref rows Extra
1661 1 SIMPLE views ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases
1662 set global init_connect="drop table if exists t1;drop table if exists t1;\
1663 drop table if exists t1;drop table if exists t1;\
1664 drop table if exists t1;drop table if exists t1;\
1665 drop table if exists t1;drop table if exists t1;\
1666 drop table if exists t1;drop table if exists t1;\
1667 drop table if exists t1;drop table if exists t1;\
1668 drop table if exists t1;drop table if exists t1;\
1669 drop table if exists t1;drop table if exists t1;\
1670 drop table if exists t1;drop table if exists t1;\
1671 drop table if exists t1;drop table if exists t1;\
1672 drop table if exists t1;drop table if exists t1;\
1673 drop table if exists t1;drop table if exists t1;\
1674 drop table if exists t1;drop table if exists t1;\
1675 drop table if exists t1;drop table if exists t1;\
1676 drop table if exists t1;drop table if exists t1;\
1677 drop table if exists t1;drop table if exists t1;\
1678 drop table if exists t1;drop table if exists t1;\
1679 drop table if exists t1;drop table if exists t1;\
1680 drop table if exists t1;drop table if exists t1;\
1681 drop table if exists t1;drop table if exists t1;\
1682 drop table if exists t1;drop table if exists t1;";
1683 select * from information_schema.global_variables where variable_name='init_connect';
1684 VARIABLE_NAME VARIABLE_VALUE
1685 INIT_CONNECT drop table if exists t1;drop table if exists t1;
1686 drop table if exists t1;drop table if exists t1;
1687 drop table if exists t1;drop table if exists t1;
1688 drop table if exists t1;drop table if exists t1;
1689 drop table if exists t1;drop table if exists t1;
1690 drop table if exists t1;drop table if exists t1;
1691 drop table if exists t1;drop table if exists t1;
1692 drop table if exists t1;drop table if exists t1;
1693 drop table if exists t1;drop table if exists t1;
1694 drop table if exists t1;drop table if exists t1;
1695 drop table if exists t1;drop table if exists t1;
1696 drop table if exists t1;drop table if exists t1;
1697 drop table if exists t1;drop table if exists t1;
1698 drop table if exists t1;drop table if exists t1;
1699 drop table if exists t1;drop table if exists t1;
1700 drop table if exists t1;drop table if exists t1;
1701 drop table if exists t1;drop table if exists t1;
1702 drop table if exists t1;drop table if exists t1;
1703 drop table if exists t1;drop table if exists t1;
1704 drop table if exists t1;drop table if exists t1;
1705 drop table if exists t1;drop table if exists
1707 Warning 1265 Data truncated for column 'VARIABLE_VALUE' at row 1
1708 set global init_connect="";
1709 create table t0 select * from information_schema.global_status where VARIABLE_NAME='COM_SELECT';
1713 select a.VARIABLE_VALUE - b.VARIABLE_VALUE from t0 b, information_schema.global_status a
1714 where a.VARIABLE_NAME = b.VARIABLE_NAME;
1715 a.VARIABLE_VALUE - b.VARIABLE_VALUE
1718 CREATE TABLE t1(a INT) KEY_BLOCK_SIZE=1;
1719 SELECT CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
1723 SET TIMESTAMP=@@TIMESTAMP + 10000000;
1724 SELECT 'OK' AS TEST_RESULT FROM INFORMATION_SCHEMA.PROCESSLIST WHERE time < 0;
1727 SET TIMESTAMP=DEFAULT;
1729 # Bug #50276: Security flaw in INFORMATION_SCHEMA.TABLES
1731 CREATE DATABASE db1;
1733 CREATE TABLE t1 (id INT);
1734 CREATE USER nonpriv;
1736 # connected as nonpriv
1738 SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
1741 USE INFORMATION_SCHEMA;
1743 SELECT COUNT(*) FROM TABLES WHERE TABLE_NAME='t1';
1751 Bug#54422 query with = 'variables'
1753 CREATE TABLE variables(f1 INT);
1754 SELECT COLUMN_DEFAULT, TABLE_NAME
1755 FROM INFORMATION_SCHEMA.COLUMNS
1756 WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = 'variables';
1757 COLUMN_DEFAULT TABLE_NAME
1759 DROP TABLE variables;
1761 # Bug #53814: NUMERIC_PRECISION for unsigned bigint field is 19,
1764 CREATE TABLE ubig (a BIGINT, b BIGINT UNSIGNED);
1765 SELECT TABLE_NAME, COLUMN_NAME, NUMERIC_PRECISION
1766 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='ubig';
1767 TABLE_NAME COLUMN_NAME NUMERIC_PRECISION
1770 INSERT INTO ubig VALUES (0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF);
1772 Warning 1264 Out of range value for column 'a' at row 1
1773 SELECT length(CAST(b AS CHAR)) FROM ubig;
1774 length(CAST(b AS CHAR))