~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/information_schema.result

Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
2
 
create database mysqltest;
3
 
create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
4
 
create table test.t2(a int);
5
 
create table t3(a int, KEY a_data (a));
6
 
create table mysqltest.t4(a int);
7
 
create table t5 (id int auto_increment primary key);
8
 
insert into t5 values (10);
9
 
select table_name from data_dictionary.tables
10
 
where table_schema = "mysqltest" and table_name like "t%";
11
 
table_name
12
 
t1
13
 
t4
14
 
select * from data_dictionary.indexes where TABLE_SCHEMA = "mysqltest";
15
 
TABLE_SCHEMA    TABLE_NAME      INDEX_NAME      IS_USED_IN_PRIMARY      IS_UNIQUE       IS_NULLABLE     KEY_LENGTH      INDEX_TYPE      INDEX_COMMENT
16
 
mysqltest       t1      string_data     NO      NO      YES     120     UNKNOWN NULL
17
 
show tables like 't%';
18
 
Tables_in_test (t%)
19
 
t2
20
 
t3
21
 
t5
22
 
show table status;
23
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
24
 
#       test    t5      STANDARD        InnoDB  #       #       #       #       #
25
 
show columns from t3 like "a%";
26
 
Field   Type    Null    Default Default_is_NULL On_Update
27
 
a       INTEGER YES             YES     
28
 
select * from data_dictionary.columns where table_name="t1"
29
 
and column_name= "a";
30
 
TABLE_SCHEMA    TABLE_NAME      COLUMN_NAME     COLUMN_TYPE     ORDINAL_POSITION        COLUMN_DEFAULT  COLUMN_DEFAULT_IS_NULL  COLUMN_DEFAULT_UPDATE   IS_AUTO_INCREMENT       IS_NULLABLE     IS_INDEXED      IS_USED_IN_PRIMARY      IS_UNIQUE       IS_MULTI        IS_FIRST_IN_MULTI       INDEXES_FOUND_IN        DATA_TYPE       CHARACTER_MAXIMUM_LENGTH        CHARACTER_OCTET_LENGTH  NUMERIC_PRECISION       NUMERIC_SCALE   ENUM_VALUES     COLLATION_NAME  COLUMN_COMMENT
31
 
mysqltest       t1      a       INTEGER 0       NULL    YES             NO      YES     NO      NO      NO      NO      NO      0       INTEGER 0       0       0       0       NULL            NULL
32
 
select table_name, column_name from data_dictionary.columns 
33
 
where table_schema = 'mysqltest' and table_name = 't1';
34
 
table_name      column_name
35
 
t1      a
36
 
t1      b
37
 
show columns from mysqltest.t1;
38
 
Field   Type    Null    Default Default_is_NULL On_Update
39
 
a       INTEGER YES             YES     
40
 
b       VARCHAR YES             YES     
41
 
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
42
 
drop database mysqltest;
43
 
select column_type from data_dictionary.columns
44
 
where table_schema="data_dictionary" and table_name="COLUMNS" and
45
 
(column_name="character_set_name" or column_name="collation_name");
46
 
column_type
47
 
VARCHAR
48
 
select count(*) from data_dictionary.tables where 
49
 
table_schema="data_dictionary" and table_name="COLUMNS";
50
 
count(*)
51
 
#
52
 
select count(*) from data_dictionary.tables
53
 
where table_schema="mysql" and table_name="user";
54
 
count(*)
55
 
#
56
 
select table_schema, table_name, column_name from data_dictionary.columns where data_type = 'longtext';
57
 
table_schema    table_name      column_name
58
 
select table_name, column_name, data_type from data_dictionary.columns where data_type = 'datetime';
59
 
table_name      column_name     data_type
60
 
SELECT COUNT(*) FROM data_dictionary.tables A
61
 
WHERE NOT EXISTS 
62
 
(SELECT * FROM data_dictionary.columns B
63
 
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
64
 
AND A.TABLE_NAME = B.TABLE_NAME);
65
 
COUNT(*)
66
 
0
67
 
create table t1
68
 
( x_bigint BIGINT,
69
 
x_integer INTEGER,
70
 
x_int int,
71
 
x_decimal DECIMAL(5,3),
72
 
x_numeric NUMERIC(5,3),
73
 
x_real REAL,
74
 
x_float FLOAT,
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
80
 
x_bigint        0       0
81
 
x_decimal       0       0
82
 
x_double_precision      0       0
83
 
x_float 0       0
84
 
x_int   0       0
85
 
x_integer       0       0
86
 
x_numeric       0       0
87
 
x_real  0       0
88
 
drop table t1;
89
 
SELECT table_schema, count(*) FROM data_dictionary.tables
90
 
WHERE table_name NOT LIKE 'ndb_%' AND 
91
 
table_name NOT LIKE 'falcon%'
92
 
GROUP BY TABLE_SCHEMA ORDER BY table_schema;
93
 
table_schema    count(*)
94
 
DATA_DICTIONARY #
95
 
INFORMATION_SCHEMA      #
96
 
create table t1(f1 LONGBLOB, f2 LONGTEXT);
97
 
select column_name,data_type,CHARACTER_OCTET_LENGTH,
98
 
CHARACTER_MAXIMUM_LENGTH
99
 
from data_dictionary.columns
100
 
where table_name='t1';
101
 
column_name     data_type       CHARACTER_OCTET_LENGTH  CHARACTER_MAXIMUM_LENGTH
102
 
f1      BLOB    0       0
103
 
f2      BLOB    0       0
104
 
drop table t1;
105
 
create table t1(f1 int, f2 int, f3 BIGINT, f4 int,
106
 
f5 BIGINT, f6 int, f7 int);
107
 
select column_name, NUMERIC_PRECISION, NUMERIC_SCALE
108
 
from data_dictionary.columns
109
 
where table_name='t1';
110
 
column_name     NUMERIC_PRECISION       NUMERIC_SCALE
111
 
f1      0       0
112
 
f2      0       0
113
 
f3      0       0
114
 
f4      0       0
115
 
f5      0       0
116
 
f6      0       0
117
 
f7      0       0
118
 
drop table t1;
119
 
create table t1 (a int not null, b int);
120
 
select column_name, column_default from data_dictionary.columns
121
 
where table_schema='test' and table_name='t1';
122
 
column_name     column_default
123
 
a       NULL
124
 
b       NULL
125
 
use test;
126
 
show columns from t1;
127
 
Field   Type    Null    Default Default_is_NULL On_Update
128
 
a       INTEGER NO              NO      
129
 
b       INTEGER YES             YES     
130
 
drop table t1;
131
 
use test;
132
 
create table t1(id int);
133
 
insert into t1(id) values (1);
134
 
select 1 from (select 1 from test.t1) a;
135
 
1
136
 
1
137
 
use data_dictionary;
138
 
select 1 from (select 1 from test.t1) a;
139
 
1
140
 
1
141
 
use test;
142
 
drop table t1;
143
 
create table t1(f1 varbinary(32), f2 varbinary(64));
144
 
select character_maximum_length, character_octet_length
145
 
from data_dictionary.columns where table_name='t1';
146
 
character_maximum_length        character_octet_length
147
 
32      128
148
 
64      256
149
 
drop table t1;
150
 
select column_type, group_concat(table_schema, '.', table_name), count(*) as num
151
 
from data_dictionary.columns where
152
 
table_schema='data_dictionary' and
153
 
(column_type = 'varchar(7)' or column_type = 'varchar(20)'
154
 
 or column_type = 'varchar(27)')
155
 
group by column_type order by column_type, num;
156
 
column_type     group_concat(table_schema, '.', table_name)     num
157
 
create table t1(f1 char(1) not null, f2 char(9) not null);
158
 
select CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH from
159
 
data_dictionary.columns where table_schema='test' and table_name = 't1';
160
 
CHARACTER_MAXIMUM_LENGTH        CHARACTER_OCTET_LENGTH
161
 
1       4
162
 
9       36
163
 
drop table t1;
164
 
set @a:= '.';
165
 
create table t1(f1 char(5));
166
 
create table t2(f1 char(5));
167
 
select concat(@a, table_name), @a, table_name
168
 
from data_dictionary.tables where table_schema = 'test';
169
 
concat(@a, table_name)  @a      table_name
170
 
.t1     .       t1
171
 
.t2     .       t2
172
 
drop table t1,t2;
173
 
SELECT t.table_name, c1.column_name
174
 
FROM data_dictionary.tables t
175
 
INNER JOIN
176
 
data_dictionary.columns c1
177
 
ON t.table_schema = c1.table_schema AND
178
 
t.table_name = c1.table_name
179
 
WHERE t.table_schema = 'data_dictionary' AND
180
 
c1.ordinal_position =
181
 
( SELECT COALESCE(MIN(c2.ordinal_position),1)
182
 
FROM data_dictionary.columns c2
183
 
WHERE c2.table_schema = t.table_schema AND
184
 
c2.table_name = t.table_name AND
185
 
c2.column_name LIKE '%SCHEMA%'
186
 
        )
187
 
AND t.table_name NOT LIKE 'falcon%'
188
 
  ORDER BY t.table_name, c1.column_name;
189
 
table_name      column_name
190
 
CHARACTER_SETS  DEFAULT_COLLATE_NAME
191
 
COLLATIONS      COLLATION_NAME
192
 
COLUMNS TABLE_SCHEMA
193
 
CUMULATIVE_SQL_COMMANDS COUNT_SELECT
194
 
CUMULATIVE_USER_STATS   BYTES_RECEIVED
195
 
CURRENT_SQL_COMMANDS    IP
196
 
DRIZZLE_PROTOCOL_STATUS VARIABLE_VALUE
197
 
ERRORS  ERROR_NAME
198
 
FOREIGN_KEYS    CONSTRAINT_SCHEMA
199
 
GLOBAL_STATEMENTS       VARIABLE_VALUE
200
 
GLOBAL_STATUS   VARIABLE_VALUE
201
 
GLOBAL_VARIABLES        VARIABLE_VALUE
202
 
INDEXES TABLE_SCHEMA
203
 
INDEX_PARTS     TABLE_SCHEMA
204
 
INNODB_CMP      COMPRESS_OPS
205
 
INNODB_CMPMEM   PAGE_SIZE
206
 
INNODB_CMPMEM_RESET     PAGE_SIZE
207
 
INNODB_CMP_RESET        COMPRESS_OPS
208
 
INNODB_LOCKS    LOCK_TRX_ID
209
 
INNODB_LOCK_WAITS       REQUESTED_LOCK_ID
210
 
INNODB_REPLICATION_LOG  TRANSACTION_MESSAGE_STRING
211
 
INNODB_STATUS   VARIABLE_VALUE
212
 
INNODB_SYS_COLUMNS      NAME
213
 
INNODB_SYS_FIELDS       NAME
214
 
INNODB_SYS_FOREIGN      FOR_NAME
215
 
INNODB_SYS_FOREIGN_COLS FOR_COL_NAME
216
 
INNODB_SYS_INDEXES      NAME
217
 
INNODB_SYS_TABLES       NAME
218
 
INNODB_SYS_TABLESTATS   NAME
219
 
INNODB_TRX      TRX_STATE
220
 
MODULES MODULE_VERSION
221
 
MYSQL_PROTOCOL_STATUS   VARIABLE_VALUE
222
 
PLUGINS PLUGIN_TYPE
223
 
PROCESSLIST     USER
224
 
REPLICATION_STREAMS     APPLIER
225
 
SCHEMAS SCHEMA_NAME
226
 
SCOREBOARD_STATISTICS   NUMBER_OF_RANGE_LOCKS
227
 
SESSION_STATEMENTS      VARIABLE_VALUE
228
 
SESSION_STATUS  VARIABLE_VALUE
229
 
SESSION_VARIABLES       VARIABLE_VALUE
230
 
TABLES  TABLE_SCHEMA
231
 
TABLE_CACHE     TABLE_SCHEMA
232
 
TABLE_CONSTRAINTS       CONSTRAINT_SCHEMA
233
 
TABLE_DEFINITION_CACHE  TABLE_SCHEMA
234
 
USER_DEFINED_BARRIERS   SESSION_ID
235
 
USER_DEFINED_LOCKS      SESSION_ID
236
 
USER_DEFINED_VARIABLES  VARIABLE_VALUE
237
 
SELECT t.table_name, c1.column_name
238
 
FROM data_dictionary.tables t
239
 
INNER JOIN
240
 
data_dictionary.columns c1
241
 
ON t.table_schema = c1.table_schema AND
242
 
t.table_name = c1.table_name
243
 
WHERE t.table_schema = 'data_dictionary' AND
244
 
c1.ordinal_position =
245
 
( SELECT COALESCE(MIN(c2.ordinal_position),1)
246
 
FROM data_dictionary.columns c2
247
 
WHERE c2.table_schema = 'data_dictionary' AND
248
 
c2.table_name = t.table_name AND
249
 
c2.column_name LIKE '%SCHEMA%'
250
 
        )
251
 
AND t.table_name NOT LIKE 'falcon%'
252
 
  ORDER BY t.table_name, c1.column_name;
253
 
table_name      column_name
254
 
CHARACTER_SETS  DEFAULT_COLLATE_NAME
255
 
COLLATIONS      COLLATION_NAME
256
 
COLUMNS TABLE_SCHEMA
257
 
CUMULATIVE_SQL_COMMANDS COUNT_SELECT
258
 
CUMULATIVE_USER_STATS   BYTES_RECEIVED
259
 
CURRENT_SQL_COMMANDS    IP
260
 
DRIZZLE_PROTOCOL_STATUS VARIABLE_VALUE
261
 
ERRORS  ERROR_NAME
262
 
FOREIGN_KEYS    CONSTRAINT_SCHEMA
263
 
GLOBAL_STATEMENTS       VARIABLE_VALUE
264
 
GLOBAL_STATUS   VARIABLE_VALUE
265
 
GLOBAL_VARIABLES        VARIABLE_VALUE
266
 
INDEXES TABLE_SCHEMA
267
 
INDEX_PARTS     TABLE_SCHEMA
268
 
INNODB_CMP      COMPRESS_OPS
269
 
INNODB_CMPMEM   PAGE_SIZE
270
 
INNODB_CMPMEM_RESET     PAGE_SIZE
271
 
INNODB_CMP_RESET        COMPRESS_OPS
272
 
INNODB_LOCKS    LOCK_TRX_ID
273
 
INNODB_LOCK_WAITS       REQUESTED_LOCK_ID
274
 
INNODB_REPLICATION_LOG  TRANSACTION_MESSAGE_STRING
275
 
INNODB_STATUS   VARIABLE_VALUE
276
 
INNODB_SYS_COLUMNS      NAME
277
 
INNODB_SYS_FIELDS       NAME
278
 
INNODB_SYS_FOREIGN      FOR_NAME
279
 
INNODB_SYS_FOREIGN_COLS FOR_COL_NAME
280
 
INNODB_SYS_INDEXES      NAME
281
 
INNODB_SYS_TABLES       NAME
282
 
INNODB_SYS_TABLESTATS   NAME
283
 
INNODB_TRX      TRX_STATE
284
 
MODULES MODULE_VERSION
285
 
MYSQL_PROTOCOL_STATUS   VARIABLE_VALUE
286
 
PLUGINS PLUGIN_TYPE
287
 
PROCESSLIST     USER
288
 
REPLICATION_STREAMS     APPLIER
289
 
SCHEMAS SCHEMA_NAME
290
 
SCOREBOARD_STATISTICS   NUMBER_OF_RANGE_LOCKS
291
 
SESSION_STATEMENTS      VARIABLE_VALUE
292
 
SESSION_STATUS  VARIABLE_VALUE
293
 
SESSION_VARIABLES       VARIABLE_VALUE
294
 
TABLES  TABLE_SCHEMA
295
 
TABLE_CACHE     TABLE_SCHEMA
296
 
TABLE_CONSTRAINTS       CONSTRAINT_SCHEMA
297
 
TABLE_DEFINITION_CACHE  TABLE_SCHEMA
298
 
USER_DEFINED_BARRIERS   SESSION_ID
299
 
USER_DEFINED_LOCKS      SESSION_ID
300
 
USER_DEFINED_VARIABLES  VARIABLE_VALUE
301
 
SELECT MAX(table_name) FROM data_dictionary.tables;
302
 
MAX(table_name)
303
 
VIEW_TABLE_USAGE
304
 
SELECT table_name from data_dictionary.tables
305
 
WHERE table_name=(SELECT MAX(table_name)
306
 
FROM data_dictionary.tables)
307
 
ORDER BY table_name;
308
 
table_name
309
 
VIEW_TABLE_USAGE
310
 
create table t1 (f1 int);
311
 
create table t2 (f1 int, f2 int);
312
 
drop table t1,t2;
313
 
select 1 as f1 from data_dictionary.tables  where "CHARACTER_SETS"=
314
 
(select cast(table_name as char)  from data_dictionary.tables
315
 
order by table_name limit 1) limit 1;
316
 
f1
317
 
1
318
 
select t.table_name, group_concat(t.table_schema, '.', t.table_name),
319
 
count(*) as num1
320
 
from data_dictionary.tables t
321
 
inner join data_dictionary.columns c1
322
 
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
323
 
where t.table_schema = 'data_dictionary' AND
324
 
t.table_name not like 'falcon%' AND
325
 
c1.ordinal_position =
326
 
(select isnull(c2.column_type) -
327
 
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +
328
 
count(*) as num
329
 
from data_dictionary.columns c2 where
330
 
c2.table_schema='data_dictionary' and
331
 
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
332
 
group by c2.column_type order by num limit 1)
333
 
group by t.table_name order by num1, t.table_name;
334
 
table_name      group_concat(t.table_schema, '.', t.table_name) num1
335
 
alter database;
336
 
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
337
 
alter database test;
338
 
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
339
 
create table t1 (
340
 
f1 varchar(50),
341
 
f2 varchar(50) not null,
342
 
f3 varchar(50) default '',
343
 
f4 varchar(50) default NULL,
344
 
f5 bigint not null,
345
 
f6 bigint not null default 10,
346
 
f7 datetime not null,
347
 
f8 datetime default '2006-01-01'
348
 
);
349
 
show columns from t1;
350
 
Field   Type    Null    Default Default_is_NULL On_Update
351
 
f1      VARCHAR YES             YES     
352
 
f2      VARCHAR NO              NO      
353
 
f3      VARCHAR YES             NO      
354
 
f4      VARCHAR YES             YES     
355
 
f5      BIGINT  NO              NO      
356
 
f6      BIGINT  NO      10      NO      
357
 
f7      DATETIME        NO              NO      
358
 
f8      DATETIME        YES     2006-01-01 00:00:00     NO      
359
 
drop table t1;
360
 
SET max_heap_table_size = DEFAULT;
361
 
USE test;
362
 
End of 5.0 tests.
363
 
SELECT SCHEMA_NAME FROM data_dictionary.schemas
364
 
WHERE SCHEMA_NAME ='data_dictionary';
365
 
SCHEMA_NAME
366
 
data_dictionary
367
 
SELECT TABLE_COLLATION FROM data_dictionary.tables
368
 
WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db';
369
 
TABLE_COLLATION
370
 
#
371
 
# Test that the query is visible to self and others.
372
 
#
373
 
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID();
374
 
info
375
 
SELECT info FROM data_dictionary.processlist WHERE id = CONNECTION_ID()
376
 
SELECT info, command, db
377
 
FROM data_dictionary.processlist
378
 
WHERE id = CONNECTION_ID();
379
 
info    command db
380
 
FROM data_dictionary.processlist
381
 
SELECT info, command, db
382
 
WHERE id = CONNECTION_ID()      Query   test