1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
|
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
select * from information_schema.SCHEMATA where schema_name > 'm';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH
NULL mysql utf8 utf8_general_ci NULL
NULL test utf8 utf8_general_ci NULL
select schema_name from information_schema.schemata;
schema_name
information_schema
mysql
test
show databases like 't%';
Database (t%)
test
show databases;
Database
information_schema
mysql
test
create 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);
select table_name from information_schema.TABLES
where table_schema = "mysqltest" and table_name like "t%";
table_name
t1
t4
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
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 INDEX_COMMENT
NULL mysqltest t1 1 mysqltest string_data 1 b A 0 NULL NULL YES BTREE
show tables like 't%';
Tables_in_test (t%)
t2
t3
t5
show full columns from t3 like "a%";
Field Type Collation Null Key Default Extra Privileges Comment
a int NULL YES MUL NULL #
select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a";
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 STORAGE FORMAT
NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 0 NULL NULL int Default Default
select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 't1';
table_name column_name privileges
t1 a
t1 b
show columns from mysqltest.t1;
Field Type Null Key Default Extra
a int YES NULL
b varchar(30) YES MUL NULL
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
drop database mysqltest;
select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like 'latin1%';
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
select * from information_schema.COLLATIONS
where COLLATION_NAME like 'latin1%';
COLLATION_NAME CHARACTER_SET_NAME DESCRIPTION ID IS_DEFAULT IS_COMPILED SORTLEN
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
where COLLATION_NAME like 'latin1%';
COLLATION_NAME CHARACTER_SET_NAME
select * from information_schema.table_names;
ERROR 42S02: Unknown table 'table_names' in information_schema
select column_type from information_schema.columns
where table_schema="information_schema" and table_name="COLUMNS" and
(column_name="character_set_name" or column_name="collation_name");
column_type
varchar(64)
varchar(64)
select TABLE_ROWS from information_schema.tables where
table_schema="information_schema" and table_name="COLUMNS";
TABLE_ROWS
NULL
select table_type from information_schema.tables
where table_schema="mysql" and table_name="user";
table_type
select table_schema,table_name, column_name from
information_schema.columns
where data_type = 'longtext';
table_schema table_name column_name
select table_name, column_name, data_type from information_schema.columns
where data_type = 'datetime';
table_name column_name data_type
INNODB_TRX trx_started datetime
INNODB_TRX trx_wait_started datetime
TABLES CREATE_TIME datetime
TABLES UPDATE_TIME datetime
TABLES CHECK_TIME datetime
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
WHERE NOT EXISTS
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME);
COUNT(*)
0
create table t1
( x_bigint BIGINT,
x_integer INTEGER,
x_int int,
x_decimal DECIMAL(5,3),
x_numeric NUMERIC(5,3),
x_real REAL,
x_float FLOAT,
x_double_precision DOUBLE PRECISION );
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME= 't1';
COLUMN_NAME CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
x_bigint NULL NULL
x_integer NULL NULL
x_int NULL NULL
x_decimal NULL NULL
x_numeric NULL NULL
x_real NULL NULL
x_float NULL NULL
x_double_precision NULL NULL
drop table t1;
SELECT table_schema, count(*) FROM information_schema.TABLES
WHERE table_name NOT LIKE 'ndb_%' AND
table_name NOT LIKE 'falcon%' AND
table_name NOT LIKE 'MEMCACHED%'
GROUP BY TABLE_SCHEMA;
table_schema count(*)
information_schema 23
show create database information_schema;
Database Create Database
information_schema CREATE DATABASE `information_schema`
create table t1(f1 LONGBLOB, f2 LONGTEXT);
select column_name,data_type,CHARACTER_OCTET_LENGTH,
CHARACTER_MAXIMUM_LENGTH
from information_schema.columns
where table_name='t1';
column_name data_type CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH
f1 blob 4294967295 4294967295
f2 text 4294967295 4294967295
drop table t1;
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
f5 BIGINT, f6 int, f7 int);
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns
where table_name='t1';
column_name NUMERIC_PRECISION NUMERIC_SCALE
f1 10 0
f2 10 0
f3 19 0
f4 10 0
f5 19 0
f6 10 0
f7 10 0
drop table t1;
create table t1 (a int not null, b int);
use information_schema;
select column_name, column_default from columns
where table_schema='test' and table_name='t1';
column_name column_default
a NULL
b NULL
use test;
show columns from t1;
Field Type Null Key Default Extra
a int NO NULL
b int YES NULL
drop table t1;
alter database information_schema;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '' at line 1
drop database information_schema;
ERROR 42000: Access denied for user ''@'' to database 'information_schema'
drop table information_schema.tables;
ERROR 42000: Access denied for user ''@'' to database 'information_schema'
alter table information_schema.tables;
ERROR 42000: Access denied for user ''@'' to database 'information_schema'
use information_schema;
create temporary table schemata(f1 char(10));
ERROR 42000: Access denied for user ''@'' to database 'information_schema'
use test;
create table t1(id int);
insert into t1(id) values (1);
select 1 from (select 1 from test.t1) a;
1
1
use information_schema;
select 1 from (select 1 from test.t1) a;
1
1
use test;
drop table t1;
create temporary table t1(f1 int, index(f1));
show columns from t1;
Field Type Null Key Default Extra
f1 int YES MUL NULL
describe t1;
Field Type Null Key Default Extra
f1 int YES MUL NULL
show indexes from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
t1 1 f1 1 f1 A 0 NULL NULL YES BTREE
drop table t1;
create table t1(f1 varbinary(32), f2 varbinary(64));
select character_maximum_length, character_octet_length
from information_schema.columns where table_name='t1';
character_maximum_length character_octet_length
32 32
64 64
drop table t1;
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
from information_schema.columns where
table_schema='information_schema' and
(column_type = 'varchar(7)' or column_type = 'varchar(20)'
or column_type = 'varchar(27)')
group by column_type order by num;
column_type group_concat(table_schema, '.', table_name) num
varchar(20) information_schema.PLUGINS 1
varchar(27) information_schema.COLUMNS 1
create table t1(f1 char(1) not null, f2 char(9) not null);
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
information_schema.columns where table_schema='test' and table_name = 't1';
CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
1 4
9 36
drop table t1;
set @a:= '.';
create table t1(f1 char(5));
create table t2(f1 char(5));
select concat(@a, table_name), @a, table_name
from information_schema.tables where table_schema = 'test';
concat(@a, table_name) @a table_name
.t1 . t1
.t2 . t2
drop table t1,t2;
SELECT t.table_name, c1.column_name
FROM information_schema.tables t
INNER JOIN
information_schema.columns c1
ON t.table_schema = c1.table_schema AND
t.table_name = c1.table_name
WHERE t.table_schema = 'information_schema' AND
c1.ordinal_position =
( SELECT COALESCE(MIN(c2.ordinal_position),1)
FROM information_schema.columns c2
WHERE c2.table_schema = t.table_schema AND
c2.table_name = t.table_name AND
c2.column_name LIKE '%SCHEMA%'
)
AND t.table_name NOT LIKE 'falcon%'
AND t.table_name NOT LIKE 'MEMCACHED%';
table_name column_name
INNODB_TRX trx_id
INNODB_LOCKS lock_id
INNODB_LOCK_WAITS requesting_trx_id
INNODB_CMP page_size
INNODB_CMP_RESET page_size
INNODB_CMPMEM page_size
INNODB_CMPMEM_RESET page_size
CHARACTER_SETS CHARACTER_SET_NAME
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
GLOBAL_STATUS VARIABLE_NAME
GLOBAL_VARIABLES VARIABLE_NAME
PLUGINS PLUGIN_NAME
PROCESSLIST ID
REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
SCHEMATA SCHEMA_NAME
SESSION_STATUS VARIABLE_NAME
SESSION_VARIABLES VARIABLE_NAME
STATISTICS TABLE_SCHEMA
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
TABLES TABLE_SCHEMA
SELECT t.table_name, c1.column_name
FROM information_schema.tables t
INNER JOIN
information_schema.columns c1
ON t.table_schema = c1.table_schema AND
t.table_name = c1.table_name
WHERE t.table_schema = 'information_schema' AND
c1.ordinal_position =
( SELECT COALESCE(MIN(c2.ordinal_position),1)
FROM information_schema.columns c2
WHERE c2.table_schema = 'information_schema' AND
c2.table_name = t.table_name AND
c2.column_name LIKE '%SCHEMA%'
)
AND t.table_name NOT LIKE 'falcon%'
AND t.table_name NOT LIKE 'MEMCACHED%';
table_name column_name
INNODB_TRX trx_id
INNODB_LOCKS lock_id
INNODB_LOCK_WAITS requesting_trx_id
INNODB_CMP page_size
INNODB_CMP_RESET page_size
INNODB_CMPMEM page_size
INNODB_CMPMEM_RESET page_size
CHARACTER_SETS CHARACTER_SET_NAME
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
GLOBAL_STATUS VARIABLE_NAME
GLOBAL_VARIABLES VARIABLE_NAME
PLUGINS PLUGIN_NAME
PROCESSLIST ID
REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
SCHEMATA SCHEMA_NAME
SESSION_STATUS VARIABLE_NAME
SESSION_VARIABLES VARIABLE_NAME
STATISTICS TABLE_SCHEMA
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
TABLES TABLE_SCHEMA
SELECT MAX(table_name) FROM information_schema.tables;
MAX(table_name)
TABLE_CONSTRAINTS
SELECT table_name from information_schema.tables
WHERE table_name=(SELECT MAX(table_name)
FROM information_schema.tables);
table_name
TABLE_CONSTRAINTS
create table t1 (f1 int);
create table t2 (f1 int, f2 int);
select table_name from information_schema.tables
where table_schema = 'test' and table_name not in
(select table_name from information_schema.columns
where table_schema = 'test' and column_name = 'f3');
table_name
t1
t2
drop table t1,t2;
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
(select cast(table_name as char) from information_schema.tables
order by table_name limit 1) limit 1;
f1
1
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
count(*) as num1
from information_schema.tables t
inner join information_schema.columns c1
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
where t.table_schema = 'information_schema' AND
t.table_name not like 'falcon%' AND
t.table_name not like 'MEMCACHED%' AND
c1.ordinal_position =
(select isnull(c2.column_type) -
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
count(*) as num
from information_schema.columns c2 where
c2.table_schema='information_schema' and
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
group by c2.column_type order by num limit 1)
group by t.table_name order by num1, t.table_name;
table_name group_concat(t.table_schema, '.', t.table_name) num1
CHARACTER_SETS information_schema.CHARACTER_SETS 1
COLLATIONS information_schema.COLLATIONS 1
COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
COLUMNS information_schema.COLUMNS 1
GLOBAL_STATUS information_schema.GLOBAL_STATUS 1
GLOBAL_VARIABLES information_schema.GLOBAL_VARIABLES 1
INNODB_CMP information_schema.INNODB_CMP 1
INNODB_CMPMEM information_schema.INNODB_CMPMEM 1
INNODB_CMPMEM_RESET information_schema.INNODB_CMPMEM_RESET 1
INNODB_CMP_RESET information_schema.INNODB_CMP_RESET 1
INNODB_LOCKS information_schema.INNODB_LOCKS 1
INNODB_LOCK_WAITS information_schema.INNODB_LOCK_WAITS 1
INNODB_TRX information_schema.INNODB_TRX 1
KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
PLUGINS information_schema.PLUGINS 1
PROCESSLIST information_schema.PROCESSLIST 1
REFERENTIAL_CONSTRAINTS information_schema.REFERENTIAL_CONSTRAINTS 1
SCHEMATA information_schema.SCHEMATA 1
SESSION_STATUS information_schema.SESSION_STATUS 1
SESSION_VARIABLES information_schema.SESSION_VARIABLES 1
STATISTICS information_schema.STATISTICS 1
TABLES information_schema.TABLES 1
TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
alter database;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '' at line 1
alter database test;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '' at line 1
create table t1 (
f1 varchar(50),
f2 varchar(50) not null,
f3 varchar(50) default '',
f4 varchar(50) default NULL,
f5 bigint not null,
f6 bigint not null default 10,
f7 datetime not null,
f8 datetime default '2006-01-01'
);
select column_default from information_schema.columns where table_name= 't1';
column_default
NULL
NULL
NULL
NULL
10
NULL
2006-01-01 00:00:00
show columns from t1;
Field Type Null Key Default Extra
f1 varchar(50) YES NULL
f2 varchar(50) NO NULL
f3 varchar(50) YES
f4 varchar(50) YES NULL
f5 bigint NO NULL
f6 bigint NO 10
f7 datetime NO NULL
f8 datetime YES 2006-01-01 00:00:00
drop table t1;
show fields from information_schema.table_names;
ERROR 42S02: Unknown table 'table_names' in information_schema
show keys from information_schema.table_names;
ERROR 42S02: Unknown table 'table_names' in information_schema
SET max_heap_table_size = DEFAULT;
USE test;
End of 5.0 tests.
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME ='information_schema';
SCHEMA_NAME
information_schema
SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
TABLE_COLLATION
select * from information_schema.columns where table_schema = NULL;
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 STORAGE FORMAT
select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL;
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 STORAGE FORMAT
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL;
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
select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL;
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
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL;
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
select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL;
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
select * from information_schema.schemata where schema_name = NULL;
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH
select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL;
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 INDEX_COMMENT
select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL;
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 INDEX_COMMENT
select * from information_schema.tables where table_schema = NULL;
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
select * from information_schema.tables where table_catalog = NULL;
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
select * from information_schema.tables where table_name = NULL;
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
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
#
# Test that the query is visible to self and others.
#
SELECT info FROM information_schema.processlist WHERE id = CONNECTION_ID();
info
SELECT info FROM information_schema.processlist WHERE id = CONNECTION_ID()
show processlist;
Id User Host db Command Time State Info
# # # mysqltest Sleep # # NULL
# # # test Sleep # # NULL
# # # test Query # # show processlist
SELECT info, command, db
FROM information_schema.processlist
WHERE id = CONNECTION_ID();
info command db
SELECT info, command, db
FROM information_schema.processlist
WHERE id = CONNECTION_ID() Query test
SELECT *
FROM information_schema.character_sets
ORDER BY character_set_name;
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
binary binary 1
utf8 utf8_general_ci UTF-8 Unicode 4
SELECT *
FROM information_schema.collations
ORDER BY collation_name;
COLLATION_NAME CHARACTER_SET_NAME DESCRIPTION ID IS_DEFAULT IS_COMPILED SORTLEN
binary binary 63 0 Yes 1 0
utf8_bin utf8 46 0 Yes 1 0
utf8_czech_ci utf8 234 0 Yes 8 0
utf8_danish_ci utf8 235 0 Yes 8 0
utf8_esperanto_ci utf8 241 0 Yes 8 0
utf8_estonian_ci utf8 230 0 Yes 8 0
utf8_general_ci utf8 45 0 Yes 1 0
utf8_hungarian_ci utf8 242 0 Yes 8 0
utf8_icelandic_ci utf8 225 0 Yes 8 0
utf8_latvian_ci utf8 226 0 Yes 8 0
utf8_lithuanian_ci utf8 236 0 Yes 8 0
utf8_persian_ci utf8 240 0 Yes 8 0
utf8_polish_ci utf8 229 0 Yes 8 0
utf8_romanian_ci utf8 227 0 Yes 8 0
utf8_roman_ci utf8 239 0 Yes 8 0
utf8_sinhala_ci utf8 243 0 Yes 8 0
utf8_slovak_ci utf8 237 0 Yes 8 0
utf8_slovenian_ci utf8 228 0 Yes 8 0
utf8_spanish2_ci utf8 238 0 Yes 8 0
utf8_spanish_ci utf8 231 0 Yes 8 0
utf8_swedish_ci utf8 232 0 Yes 8 0
utf8_turkish_ci utf8 233 0 Yes 8 0
utf8_unicode_ci utf8 224 0 Yes 8 0
SELECT *
FROM information_schema.collation_character_set_applicability
ORDER BY collation_name;
COLLATION_NAME CHARACTER_SET_NAME
binary binary
utf8_bin utf8
utf8_czech_ci utf8
utf8_danish_ci utf8
utf8_esperanto_ci utf8
utf8_estonian_ci utf8
utf8_general_ci utf8
utf8_hungarian_ci utf8
utf8_icelandic_ci utf8
utf8_latvian_ci utf8
utf8_lithuanian_ci utf8
utf8_persian_ci utf8
utf8_polish_ci utf8
utf8_romanian_ci utf8
utf8_roman_ci utf8
utf8_sinhala_ci utf8
utf8_slovak_ci utf8
utf8_slovenian_ci utf8
utf8_spanish2_ci utf8
utf8_spanish_ci utf8
utf8_swedish_ci utf8
utf8_turkish_ci utf8
utf8_unicode_ci utf8
SELECT table_name, column_name
FROM information_schema.columns
WHERE table_name NOT LIKE 'MEMCACHED%'
ORDER BY table_name;
table_name column_name
CHARACTER_SETS MAXLEN
CHARACTER_SETS DESCRIPTION
CHARACTER_SETS DEFAULT_COLLATE_NAME
CHARACTER_SETS CHARACTER_SET_NAME
COLLATIONS IS_COMPILED
COLLATIONS COLLATION_NAME
COLLATIONS SORTLEN
COLLATIONS IS_DEFAULT
COLLATIONS ID
COLLATIONS DESCRIPTION
COLLATIONS CHARACTER_SET_NAME
COLLATION_CHARACTER_SET_APPLICABILITY CHARACTER_SET_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS PRIVILEGES
COLUMNS TABLE_SCHEMA
COLUMNS TABLE_NAME
COLUMNS TABLE_CATALOG
COLUMNS COLUMN_NAME
COLUMNS ORDINAL_POSITION
COLUMNS COLUMN_DEFAULT
COLUMNS IS_NULLABLE
COLUMNS FORMAT
COLUMNS COLLATION_NAME
COLUMNS CHARACTER_SET_NAME
COLUMNS COLUMN_COMMENT
COLUMNS COLUMN_TYPE
COLUMNS COLUMN_KEY
COLUMNS EXTRA
COLUMNS STORAGE
COLUMNS NUMERIC_SCALE
COLUMNS NUMERIC_PRECISION
COLUMNS CHARACTER_OCTET_LENGTH
COLUMNS DATA_TYPE
COLUMNS CHARACTER_MAXIMUM_LENGTH
GLOBAL_STATUS VARIABLE_NAME
GLOBAL_STATUS VARIABLE_VALUE
GLOBAL_VARIABLES VARIABLE_VALUE
GLOBAL_VARIABLES VARIABLE_NAME
INNODB_CMP compress_time
INNODB_CMP uncompress_ops
INNODB_CMP compress_ops
INNODB_CMP page_size
INNODB_CMP uncompress_time
INNODB_CMP compress_ops_ok
INNODB_CMPMEM relocation_time
INNODB_CMPMEM relocation_ops
INNODB_CMPMEM pages_used
INNODB_CMPMEM page_size
INNODB_CMPMEM pages_free
INNODB_CMPMEM_RESET relocation_time
INNODB_CMPMEM_RESET relocation_ops
INNODB_CMPMEM_RESET pages_free
INNODB_CMPMEM_RESET pages_used
INNODB_CMPMEM_RESET page_size
INNODB_CMP_RESET page_size
INNODB_CMP_RESET compress_ops
INNODB_CMP_RESET compress_ops_ok
INNODB_CMP_RESET compress_time
INNODB_CMP_RESET uncompress_ops
INNODB_CMP_RESET uncompress_time
INNODB_LOCKS lock_index
INNODB_LOCKS lock_table
INNODB_LOCKS lock_type
INNODB_LOCKS lock_trx_id
INNODB_LOCKS lock_id
INNODB_LOCKS lock_mode
INNODB_LOCKS lock_space
INNODB_LOCKS lock_page
INNODB_LOCKS lock_rec
INNODB_LOCKS lock_data
INNODB_LOCK_WAITS blocking_lock_id
INNODB_LOCK_WAITS blocking_trx_id
INNODB_LOCK_WAITS requested_lock_id
INNODB_LOCK_WAITS requesting_trx_id
INNODB_TRX trx_id
INNODB_TRX trx_state
INNODB_TRX trx_started
INNODB_TRX trx_requested_lock_id
INNODB_TRX trx_wait_started
INNODB_TRX trx_weight
INNODB_TRX trx_mysql_thread_id
INNODB_TRX trx_query
KEY_COLUMN_USAGE REFERENCED_COLUMN_NAME
KEY_COLUMN_USAGE REFERENCED_TABLE_NAME
KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA
KEY_COLUMN_USAGE POSITION_IN_UNIQUE_CONSTRAINT
KEY_COLUMN_USAGE ORDINAL_POSITION
KEY_COLUMN_USAGE CONSTRAINT_CATALOG
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
KEY_COLUMN_USAGE CONSTRAINT_NAME
KEY_COLUMN_USAGE TABLE_CATALOG
KEY_COLUMN_USAGE TABLE_SCHEMA
KEY_COLUMN_USAGE TABLE_NAME
KEY_COLUMN_USAGE COLUMN_NAME
PLUGINS PLUGIN_LICENSE
PLUGINS PLUGIN_DESCRIPTION
PLUGINS PLUGIN_AUTHOR
PLUGINS PLUGIN_STATUS
PLUGINS PLUGIN_VERSION
PLUGINS PLUGIN_NAME
PROCESSLIST INFO
PROCESSLIST STATE
PROCESSLIST TIME
PROCESSLIST COMMAND
PROCESSLIST DB
PROCESSLIST HOST
PROCESSLIST USER
PROCESSLIST ID
REFERENTIAL_CONSTRAINTS REFERENCED_TABLE_NAME
REFERENTIAL_CONSTRAINTS TABLE_NAME
REFERENTIAL_CONSTRAINTS DELETE_RULE
REFERENTIAL_CONSTRAINTS UPDATE_RULE
REFERENTIAL_CONSTRAINTS MATCH_OPTION
REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_NAME
REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_SCHEMA
REFERENTIAL_CONSTRAINTS UNIQUE_CONSTRAINT_CATALOG
REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME
REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG
SCHEMATA SQL_PATH
SCHEMATA DEFAULT_COLLATION_NAME
SCHEMATA DEFAULT_CHARACTER_SET_NAME
SCHEMATA SCHEMA_NAME
SCHEMATA CATALOG_NAME
SESSION_STATUS VARIABLE_VALUE
SESSION_STATUS VARIABLE_NAME
SESSION_VARIABLES VARIABLE_NAME
SESSION_VARIABLES VARIABLE_VALUE
STATISTICS CARDINALITY
STATISTICS SUB_PART
STATISTICS PACKED
STATISTICS NULLABLE
STATISTICS INDEX_TYPE
STATISTICS COMMENT
STATISTICS INDEX_COMMENT
STATISTICS COLLATION
STATISTICS COLUMN_NAME
STATISTICS TABLE_CATALOG
STATISTICS TABLE_SCHEMA
STATISTICS TABLE_NAME
STATISTICS NON_UNIQUE
STATISTICS INDEX_SCHEMA
STATISTICS INDEX_NAME
STATISTICS SEQ_IN_INDEX
TABLES AVG_ROW_LENGTH
TABLES DATA_LENGTH
TABLES MAX_DATA_LENGTH
TABLES INDEX_LENGTH
TABLES DATA_FREE
TABLES AUTO_INCREMENT
TABLES CREATE_TIME
TABLES UPDATE_TIME
TABLES CHECK_TIME
TABLES TABLE_COLLATION
TABLES CHECKSUM
TABLES CREATE_OPTIONS
TABLES TABLE_ROWS
TABLES ROW_FORMAT
TABLES TABLE_COMMENT
TABLES TABLE_CATALOG
TABLES TABLE_SCHEMA
TABLES TABLE_NAME
TABLES TABLE_TYPE
TABLES ENGINE
TABLES VERSION
TABLE_CONSTRAINTS TABLE_NAME
TABLE_CONSTRAINTS TABLE_SCHEMA
TABLE_CONSTRAINTS CONSTRAINT_NAME
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
TABLE_CONSTRAINTS CONSTRAINT_CATALOG
TABLE_CONSTRAINTS CONSTRAINT_TYPE
SELECT *
FROM information_schema.key_column_usage;
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
SELECT *
FROM information_schema.referential_constraints;
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
SELECT catalog_name, schema_name
FROM information_schema.schemata
ORDER BY schema_name;
catalog_name schema_name
NULL information_schema
NULL mysql
NULL test
SELECT *
FROM information_schema.session_status
ORDER BY variable_name;
VARIABLE_NAME VARIABLE_VALUE
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
SHOW STATUS;
Variable_name Value
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
SELECT *
FROM information_schema.global_status
ORDER BY variable_name;
VARIABLE_NAME VARIABLE_VALUE
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
SELECT *
FROM information_schema.table_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_name NOT LIKE 'MEMCACHED%'
ORDER BY table_name;
table_schema table_name
information_schema CHARACTER_SETS
information_schema COLLATIONS
information_schema COLLATION_CHARACTER_SET_APPLICABILITY
information_schema COLUMNS
information_schema GLOBAL_STATUS
information_schema GLOBAL_VARIABLES
information_schema INNODB_CMP
information_schema INNODB_CMPMEM
information_schema INNODB_CMPMEM_RESET
information_schema INNODB_CMP_RESET
information_schema INNODB_LOCKS
information_schema INNODB_LOCK_WAITS
information_schema INNODB_TRX
information_schema KEY_COLUMN_USAGE
information_schema PLUGINS
information_schema PROCESSLIST
information_schema REFERENTIAL_CONSTRAINTS
information_schema SCHEMATA
information_schema SESSION_STATUS
information_schema SESSION_VARIABLES
information_schema STATISTICS
information_schema TABLES
information_schema TABLE_CONSTRAINTS
|