1
1
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
2
show variables where variable_name like "skip_show_database";
2
5
select * from information_schema.SCHEMATA where schema_name > 'm';
3
6
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH
4
NULL mysql utf8 utf8_general_ci NULL
5
NULL test utf8 utf8_general_ci NULL
7
NULL mysql latin1 latin1_swedish_ci NULL
8
NULL test latin1 latin1_swedish_ci NULL
6
9
select schema_name from information_schema.schemata;
31
36
select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
32
37
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
33
NULL mysqltest t1 1 mysqltest string_data 1 b A 0 NULL NULL YES BTREE
38
NULL mysqltest t1 1 mysqltest string_data 1 b A NULL NULL NULL YES BTREE
39
show keys from t3 where Key_name = "a_data";
40
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
41
t3 1 a_data 1 a A NULL NULL NULL YES BTREE
34
42
show tables like 't%';
35
43
Tables_in_test (t%)
40
48
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
41
t2 InnoDB 10 Compact 0 0 16384 # 0 0 NULL # # NULL utf8_general_ci NULL
42
t3 InnoDB 10 Compact 0 0 16384 # 16384 0 NULL # # NULL utf8_general_ci NULL
43
t5 InnoDB 10 Compact 1 16384 16384 # 0 0 11 # # NULL utf8_general_ci NULL
49
t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
50
t3 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
51
t5 MyISAM 10 Fixed 1 7 7 # 2048 0 11 # # NULL latin1_swedish_ci NULL
44
52
show full columns from t3 like "a%";
45
53
Field Type Collation Null Key Default Extra Privileges Comment
46
a int NULL YES MUL NULL
54
a int(11) NULL YES MUL NULL
55
show full columns from mysql.db like "Insert%";
56
Field Type Collation Null Key Default Extra Privileges Comment
57
Insert_priv enum('N','Y') utf8_general_ci NO NULL
47
58
select * from information_schema.COLUMNS where table_name="t1"
48
59
and column_name= "a";
49
60
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
50
NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 0 NULL NULL int Default Default
61
NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 0 NULL NULL int(11) Default Default
62
show columns from mysqltest.t1 where field like "%a%";
63
Field Type Null Key Default Extra
51
65
select table_name, column_name, privileges from information_schema.columns
52
66
where table_schema = 'mysqltest' and table_name = 't1';
53
67
table_name column_name privileges
56
70
show columns from mysqltest.t1;
57
71
Field Type Null Key Default Extra
59
73
b varchar(30) YES MUL NULL
60
74
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
61
75
drop database mysqltest;
62
76
select * from information_schema.CHARACTER_SETS
63
77
where CHARACTER_SET_NAME like 'latin1%';
64
78
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
79
latin1 latin1_swedish_ci cp1252 West European 1
80
SHOW CHARACTER SET LIKE 'latin1%';
81
Charset Description Default collation Maxlen
82
latin1 cp1252 West European latin1_swedish_ci 1
83
SHOW CHARACTER SET WHERE charset like 'latin1%';
84
Charset Description Default collation Maxlen
85
latin1 cp1252 West European latin1_swedish_ci 1
65
86
select * from information_schema.COLLATIONS
66
87
where COLLATION_NAME like 'latin1%';
67
88
COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
89
latin1_german1_ci latin1 5 # 1
90
latin1_swedish_ci latin1 8 Yes # 1
91
latin1_danish_ci latin1 15 # 1
92
latin1_german2_ci latin1 31 # 2
93
latin1_bin latin1 47 # 1
94
latin1_general_ci latin1 48 # 1
95
latin1_general_cs latin1 49 # 1
96
latin1_spanish_ci latin1 94 # 1
97
SHOW COLLATION LIKE 'latin1%';
98
Collation Charset Id Default Compiled Sortlen
99
latin1_german1_ci latin1 5 # 1
100
latin1_swedish_ci latin1 8 Yes # 1
101
latin1_danish_ci latin1 15 # 1
102
latin1_german2_ci latin1 31 # 2
103
latin1_bin latin1 47 # 1
104
latin1_general_ci latin1 48 # 1
105
latin1_general_cs latin1 49 # 1
106
latin1_spanish_ci latin1 94 # 1
107
SHOW COLLATION WHERE collation like 'latin1%';
108
Collation Charset Id Default Compiled Sortlen
109
latin1_german1_ci latin1 5 # 1
110
latin1_swedish_ci latin1 8 Yes # 1
111
latin1_danish_ci latin1 15 # 1
112
latin1_german2_ci latin1 31 # 2
113
latin1_bin latin1 47 # 1
114
latin1_general_ci latin1 48 # 1
115
latin1_general_cs latin1 49 # 1
116
latin1_spanish_ci latin1 94 # 1
68
117
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
69
118
where COLLATION_NAME like 'latin1%';
70
119
COLLATION_NAME CHARACTER_SET_NAME
120
latin1_german1_ci latin1
121
latin1_swedish_ci latin1
122
latin1_danish_ci latin1
123
latin1_german2_ci latin1
125
latin1_general_ci latin1
126
latin1_general_cs latin1
127
latin1_spanish_ci latin1
71
128
select * from information_schema.table_names;
72
129
ERROR 42S02: Unknown table 'table_names' in information_schema
73
130
select column_type from information_schema.columns
83
140
select table_type from information_schema.tables
84
141
where table_schema="mysql" and table_name="user";
144
show open tables where `table` like "user";
145
Database Table In_use Name_locked
146
show status where variable_name like "%database%";
149
show variables where variable_name like "skip_show_databas";
86
151
show global status like "Threads_running";
87
152
Variable_name Value
90
155
information_schema.columns
91
156
where data_type = 'longtext';
92
157
table_schema table_name column_name
158
information_schema COLUMNS COLUMN_DEFAULT
159
information_schema COLUMNS COLUMN_TYPE
160
information_schema PLUGINS PLUGIN_DESCRIPTION
161
information_schema PROCESSLIST INFO
93
162
select table_name, column_name, data_type from information_schema.columns
94
163
where data_type = 'datetime';
95
164
table_name column_name data_type
129
198
WHERE table_name NOT LIKE 'ndb_%' AND table_name NOT LIKE 'falcon%' GROUP BY TABLE_SCHEMA;
130
199
table_schema count(*)
131
200
information_schema 16
132
202
show create database information_schema;
133
203
Database Create Database
134
information_schema CREATE DATABASE `information_schema` /*!40100 DEFAULT CHARACTER SET utf8 */
204
information_schema CREATE DATABASE "information_schema" /*!40100 DEFAULT CHARACTER SET utf8 */
135
205
create table t1(f1 LONGBLOB, f2 LONGTEXT);
136
206
select column_name,data_type,CHARACTER_OCTET_LENGTH,
137
207
CHARACTER_MAXIMUM_LENGTH
138
208
from information_schema.columns
139
209
where table_name='t1';
140
210
column_name data_type CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH
141
f1 blob 4294967295 4294967295
142
f2 text 4294967295 4294967295
211
f1 longblob 4294967295 4294967295
212
f2 longtext 4294967295 4294967295
144
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
145
f5 BIGINT, f6 int, f7 int);
214
create table t1(f1 tinyint, f2 SMALLINT, f3 mediumint, f4 int,
215
f5 BIGINT, f6 BIT, f7 bit(64));
146
216
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
147
217
from information_schema.columns
148
218
where table_name='t1';
149
219
column_name NUMERIC_PRECISION NUMERIC_SCALE
158
228
create table t1 (a int not null, b int);
159
229
use information_schema;
166
236
show columns from t1;
167
237
Field Type Null Key Default Extra
241
CREATE TABLE t1 (a int);
242
CREATE TABLE t2 (b int);
243
SHOW TABLE STATUS FROM test
244
WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
245
WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
246
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
247
t1 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
248
t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
171
250
alter database information_schema;
172
251
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
173
252
drop database information_schema;
194
273
create temporary table t1(f1 int, index(f1));
195
274
show columns from t1;
196
275
Field Type Null Key Default Extra
276
f1 int(11) YES MUL NULL
199
278
Field Type Null Key Default Extra
279
f1 int(11) YES MUL NULL
201
280
show indexes from t1;
202
281
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
203
t1 1 f1 1 f1 A 0 NULL NULL YES BTREE
282
t1 1 f1 1 f1 A NULL NULL NULL YES BTREE
205
create table t1(f1 varbinary(32), f2 varbinary(64));
284
create table t1(f1 binary(32), f2 varbinary(64));
206
285
select character_maximum_length, character_octet_length
207
286
from information_schema.columns where table_name='t1';
208
287
character_maximum_length character_octet_length
216
295
or column_type = 'varchar(27)')
217
296
group by column_type order by num;
218
297
column_type group_concat(table_schema, '.', table_name) num
219
varchar(20) information_schema.PLUGINS 1
220
298
varchar(27) information_schema.COLUMNS 1
221
create table t1(f1 char(1) not null, f2 char(9) not null);
299
varchar(20) information_schema.PLUGINS,information_schema.PLUGINS,information_schema.PLUGINS 3
300
create table t1(f1 char(1) not null, f2 char(9) not null)
301
default character set utf8;
222
302
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
223
303
information_schema.columns where table_schema='test' and table_name = 't1';
224
304
CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
300
380
TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
301
381
SELECT MAX(table_name) FROM information_schema.tables;
304
384
SELECT table_name from information_schema.tables
305
385
WHERE table_name=(SELECT MAX(table_name)
306
386
FROM information_schema.tables);
309
create table t1 (f1 int);
310
create table t2 (f1 int, f2 int);
389
create table t1 (f1 int(11));
390
create table t2 (f1 int(11), f2 int(11));
311
391
select table_name from information_schema.tables
312
392
where table_schema = 'test' and table_name not in
313
393
(select table_name from information_schema.columns
340
420
table_name group_concat(t.table_schema, '.', t.table_name) num1
341
421
CHARACTER_SETS information_schema.CHARACTER_SETS 1
342
422
COLLATIONS information_schema.COLLATIONS 1
343
COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
344
423
COLUMNS information_schema.COLUMNS 1
345
GLOBAL_STATUS information_schema.GLOBAL_STATUS 1
346
GLOBAL_VARIABLES information_schema.GLOBAL_VARIABLES 1
347
424
KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
348
425
PLUGINS information_schema.PLUGINS 1
349
426
PROCESSLIST information_schema.PROCESSLIST 1
350
427
REFERENTIAL_CONSTRAINTS information_schema.REFERENTIAL_CONSTRAINTS 1
351
428
SCHEMATA information_schema.SCHEMATA 1
352
SESSION_STATUS information_schema.SESSION_STATUS 1
353
SESSION_VARIABLES information_schema.SESSION_VARIABLES 1
354
429
STATISTICS information_schema.STATISTICS 1
355
430
TABLES information_schema.TABLES 1
356
431
TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1