1
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
2
DROP SCHEMA IF EXISTS data_dictionary;
3
CREATE SCHEMA data_dictionary;
4
select * from data_dictionary.SCHEMAS where schema_name > 'm';
5
SCHEMA_NAME DEFAULT_COLLATION_NAME
6
select schema_name from data_dictionary.schemas;
12
create database mysqltest;
13
create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
14
create table test.t2(a int);
15
create table t3(a int, KEY a_data (a));
16
create table mysqltest.t4(a int);
17
create table t5 (id int auto_increment primary key);
18
insert into t5 values (10);
19
select table_name from data_dictionary.TABLES
20
where table_schema = "mysqltest" and table_name like "t%";
24
select * from data_dictionary.COLUMNS where table_name="t1"
26
TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATATYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE COLLATION_NAME COLUMN_COMMENT
27
mysqltest t1 a 0 TRUE 4 # 0 0 0 # #
28
select table_name, column_name from data_dictionary.columns
29
where table_schema = 'mysqltest' and table_name = 't1';
30
table_name column_name
33
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
34
drop database mysqltest;
35
select * from data_dictionary.CHARACTER_SETS
36
where CHARACTER_SET_NAME like 'latin1%';
37
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
38
select * from data_dictionary.COLLATIONS
39
where COLLATION_NAME like 'latin1%';
40
CHARACTER_SET_NAME COLLATION_NAME DESCRIPTION ID IS_DEFAULT IS_COMPILED SORTLEN
41
select DATATYPE from data_dictionary.columns
42
where table_schema="data_dictionary" and table_name="COLUMNS" and
43
(column_name="character_set_name" or column_name="collation_name");
46
select TABLE_TYPE from data_dictionary.tables where
47
table_schema="data_dictionary" and table_name="COLUMNS";
50
select table_type from data_dictionary.tables
51
where table_schema="mysql" and table_name="user";
53
select table_schema,table_name, column_name from
54
data_dictionary.columns
55
where DATATYPE = 'longtext';
56
table_schema table_name column_name
57
select table_name, column_name, DATATYPE from data_dictionary.columns
58
where DATATYPE = 'datetime';
59
table_name column_name DATATYPE
60
SELECT COUNT(*) FROM DATA_DICTIONARY.TABLES A
62
(SELECT * FROM DATA_DICTIONARY.COLUMNS B
63
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
64
AND A.TABLE_NAME = B.TABLE_NAME);
71
x_decimal DECIMAL(5,3),
72
x_numeric NUMERIC(5,3),
75
x_double_precision DOUBLE PRECISION );
76
SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
77
FROM DATA_DICTIONARY.COLUMNS
78
WHERE TABLE_NAME= 't1';
79
COLUMN_NAME CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
87
x_double_precision 0 0
89
SELECT table_schema, count(*) FROM data_dictionary.TABLES
90
WHERE table_name NOT LIKE 'ndb_%' AND
91
table_name NOT LIKE 'falcon%' AND
93
GROUP BY TABLE_SCHEMA;
95
create table t1(f1 LONGBLOB, f2 LONGTEXT);
96
select column_name,DATATYPE,CHARACTER_OCTET_LENGTH,
97
CHARACTER_MAXIMUM_LENGTH
98
from data_dictionary.columns
99
where table_name='t1';
100
column_name DATATYPE CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH
104
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
105
f5 BIGINT, f6 int, f7 int);
106
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
107
from data_dictionary.columns
108
where table_name='t1';
109
column_name NUMERIC_PRECISION NUMERIC_SCALE
118
create table t1 (a int not null, b int);
120
select column_name, column_default from columns
121
where table_schema='test' and table_name='t1';
122
column_name column_default
127
alter database data_dictionary;
128
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
131
create temporary table schemas(f1 char(10));
132
ERROR 42000: Access denied for user ''@'' to database 'data_dictionary'
134
create table t1(id int);
135
insert into t1(id) values (1);
136
select 1 from (select 1 from test.t1) a;
140
select 1 from (select 1 from test.t1) a;
145
create temporary table t1(f1 int, index(f1));
147
create table t1(f1 varbinary(32), f2 varbinary(64));
148
select character_maximum_length, character_octet_length
149
from data_dictionary.columns where table_name='t1';
150
character_maximum_length character_octet_length
154
select DATATYPE, group_concat(table_schema, '.', table_name), count(*) as num
155
from data_dictionary.columns where
156
table_schema='data_dictionary' and
157
(DATATYPE = 'varchar' or DATATYPE = 'varchar'
158
or DATATYPE = 'varchar')
159
group by DATATYPE order by DATATYPE, num;
160
DATATYPE group_concat(table_schema, '.', table_name) num
161
create table t1(f1 char(1) not null, f2 char(9) not null);
162
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
163
data_dictionary.columns where table_schema='test' and table_name = 't1';
164
CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH
169
create table t1(f1 char(5));
170
create table t2(f1 char(5));
171
select concat(@a, table_name), @a, table_name
172
from data_dictionary.tables where table_schema = 'test';
173
concat(@a, table_name) @a table_name
177
SELECT t.table_name, c1.column_name
178
FROM data_dictionary.tables t
180
data_dictionary.columns c1
181
ON t.table_schema = c1.table_schema AND
182
t.table_name = c1.table_name
183
WHERE t.table_schema = 'data_dictionary' AND
184
c1.ordinal_position =
185
( SELECT COALESCE(MIN(c2.ordinal_position),1)
186
FROM data_dictionary.columns c2
187
WHERE c2.table_schema = t.table_schema AND
188
c2.table_name = t.table_name AND
189
c2.column_name LIKE '%SCHEMA%'
191
AND t.table_name NOT LIKE 'falcon%'
192
AND t.ENGINE IS NULL;
193
table_name column_name
194
SELECT t.table_name, c1.column_name
195
FROM data_dictionary.tables t
197
data_dictionary.columns c1
198
ON t.table_schema = c1.table_schema AND
199
t.table_name = c1.table_name
200
WHERE t.table_schema = 'data_dictionary' AND
201
c1.ordinal_position =
202
( SELECT COALESCE(MIN(c2.ordinal_position),1)
203
FROM data_dictionary.columns c2
204
WHERE c2.table_schema = 'data_dictionary' AND
205
c2.table_name = t.table_name AND
206
c2.column_name LIKE '%SCHEMA%'
208
AND t.table_name NOT LIKE 'falcon%'
209
AND t.ENGINE IS NULL;
210
table_name column_name
211
SELECT MAX(table_name) FROM data_dictionary.tables;
214
SELECT table_name from data_dictionary.tables
215
WHERE table_name=(SELECT MAX(table_name)
216
FROM data_dictionary.tables);
219
create table t1 (f1 int);
220
create table t2 (f1 int, f2 int);
221
select table_name from data_dictionary.tables
222
where table_schema = 'test' and table_name not in
223
(select table_name from data_dictionary.columns
224
where table_schema = 'test' and column_name = 'f3');
229
select 1 as f1 from data_dictionary.tables where "CHARACTER_SETS"=
230
(select cast(table_name as char) from data_dictionary.tables
231
order by table_name limit 1) limit 1;
234
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
236
from data_dictionary.tables t
237
inner join data_dictionary.columns c1
238
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
239
where t.table_schema = 'data_dictionary' AND
240
t.table_name not like 'falcon%' AND
242
c1.ordinal_position =
243
(select isnull(c2.DATATYPE) -
244
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
246
from data_dictionary.columns c2 where
247
c2.table_schema='data_dictionary' and
248
(c2.DATATYPE = 'varchar' or c2.DATATYPE = 'varchar')
249
group by c2.DATATYPE order by num limit 1)
250
group by t.table_name order by num1, t.table_name;
251
table_name group_concat(t.table_schema, '.', t.table_name) num1
253
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
255
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
258
f2 varchar(50) not null,
259
f3 varchar(50) default '',
260
f4 varchar(50) default NULL,
262
f6 bigint not null default 10,
263
f7 datetime not null,
264
f8 datetime default '2006-01-01'
266
select column_default from data_dictionary.columns where table_name= 't1';
277
SET max_heap_table_size = DEFAULT;
280
SELECT SCHEMA_NAME FROM DATA_DICTIONARY.SCHEMAS
281
WHERE SCHEMA_NAME ='data_dictionary';
284
SELECT TABLE_COLLATION FROM DATA_DICTIONARY.TABLES
285
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
287
select * from data_dictionary.columns where table_schema = NULL;
288
TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATATYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE COLLATION_NAME COLUMN_COMMENT
289
select * from `data_dictionary`.`COLUMNS` where `TABLE_NAME` = NULL;
290
TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATATYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE COLLATION_NAME COLUMN_COMMENT
291
select * from `data_dictionary`.`INDEXES` where `TABLE_SCHEMA` = NULL;
292
TABLE_SCHEMA TABLE_NAME INDEX_NAME IS_PRIMARY IS_UNIQUE IS_NULLABLE KEY_LENGTH INDEX_TYPE INDEX_COMMENT
293
select * from `data_dictionary`.`INDEXES` where `TABLE_NAME` = NULL;
294
TABLE_SCHEMA TABLE_NAME INDEX_NAME IS_PRIMARY IS_UNIQUE IS_NULLABLE KEY_LENGTH INDEX_TYPE INDEX_COMMENT
295
select * from data_dictionary.schemas where schema_name = NULL;
296
SCHEMA_NAME DEFAULT_COLLATION_NAME
297
select * from data_dictionary.tables where table_schema = NULL;
298
TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE ROW_FORMAT TABLE_COLLATION TABLE_COMMENT
299
select * from data_dictionary.tables where table_name = NULL;
300
TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE ROW_FORMAT TABLE_COLLATION TABLE_COMMENT
302
# Test that the query is visible to self and others.
304
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
306
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID()
307
SELECT * FROM data_dictionary.character_sets ORDER BY character_set_name;
308
CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
311
SELECT * FROM data_dictionary.collations ORDER BY collation_name;
312
CHARACTER_SET_NAME COLLATION_NAME DESCRIPTION ID IS_DEFAULT IS_COMPILED SORTLEN
313
binary binary binary 63 TRUE TRUE 1
314
utf8_general_ci utf8_bin utf8 46 FALSE TRUE 1
315
utf8_general_ci utf8_czech_ci utf8 234 FALSE TRUE 8
316
utf8_general_ci utf8_danish_ci utf8 235 FALSE TRUE 8
317
utf8_general_ci utf8_esperanto_ci utf8 241 FALSE TRUE 8
318
utf8_general_ci utf8_estonian_ci utf8 230 FALSE TRUE 8
319
utf8_general_ci utf8_general_ci utf8 45 TRUE TRUE 1
320
utf8_general_ci utf8_hungarian_ci utf8 242 FALSE TRUE 8
321
utf8_general_ci utf8_icelandic_ci utf8 225 FALSE TRUE 8
322
utf8_general_ci utf8_latvian_ci utf8 226 FALSE TRUE 8
323
utf8_general_ci utf8_lithuanian_ci utf8 236 FALSE TRUE 8
324
utf8_general_ci utf8_persian_ci utf8 240 FALSE TRUE 8
325
utf8_general_ci utf8_polish_ci utf8 229 FALSE TRUE 8
326
utf8_general_ci utf8_romanian_ci utf8 227 FALSE TRUE 8
327
utf8_general_ci utf8_roman_ci utf8 239 FALSE TRUE 8
328
utf8_general_ci utf8_sinhala_ci utf8 243 FALSE TRUE 8
329
utf8_general_ci utf8_slovak_ci utf8 237 FALSE TRUE 8
330
utf8_general_ci utf8_slovenian_ci utf8 228 FALSE TRUE 8
331
utf8_general_ci utf8_spanish2_ci utf8 238 FALSE TRUE 8
332
utf8_general_ci utf8_spanish_ci utf8 231 FALSE TRUE 8
333
utf8_general_ci utf8_swedish_ci utf8 232 FALSE TRUE 8
334
utf8_general_ci utf8_turkish_ci utf8 233 FALSE TRUE 8
335
utf8_general_ci utf8_unicode_ci utf8 224 FALSE TRUE 8
336
SELECT table_name, column_name
337
FROM data_dictionary.columns
339
(SELECT table_name FROM data_dictionary.tables
340
WHERE ENGINE IS NULL)
342
table_name column_name
343
SELECT schema_name FROM data_dictionary.schemas ORDER BY schema_name;
349
SELECT count(*) FROM data_dictionary.session_status ORDER BY variable_name;
352
SELECT count(*) FROM data_dictionary.session_variables ORDER BY variable_name;
355
SELECT count(*) FROM data_dictionary.global_status ORDER BY variable_name;
358
SELECT count(*) FROM data_dictionary.global_variables ORDER BY variable_name;
361
SELECT table_schema, table_name FROM data_dictionary.tables WHERE ENGINE IS NULL ORDER BY table_name;
362
table_schema table_name
363
SELECT count(*) FROM data_dictionary.plugins;
366
DROP SCHEMA IF EXISTS data_dictionary;