mariadb/mysql-test/r/information_schema.result

442 lines
17 KiB
Text
Raw Normal View History

grant all privileges on test.* to mysqltest_1@localhost;
select * from information_schema.SCHEMATA where schema_name > 'm';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME
2004-11-15 17:20:45 +01:00
NULL mysql latin1
NULL test latin1
select schema_name from information_schema.schemata;
schema_name
mysql
test
show databases *;
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME
2004-11-15 17:20:45 +01:00
NULL mysql latin1
NULL test latin1
show databases like 't%';
Database (t%)
test
show databases;
Database
mysql
test
show databases * where schema_name like 't%';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME
2004-11-15 17:20:45 +01:00
NULL test latin1
show databases * where schema_name = 't%';
CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME
create database testtets;
create table testtets.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 testtets.t4(a int);
create view v1 (c) as select table_name from information_schema.TABLES;
select * from v1;
c
columns_priv
db
func
help_category
help_keyword
help_relation
help_topic
host
proc
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user
t2
t3
v1
t1
t4
select c,table_name from v1
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
c table_name
tables_priv tables_priv
time_zone time_zone
time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_transition time_zone_transition
time_zone_transition_type time_zone_transition_type
t2 t2
t3 t3
t1 t1
t4 t4
select c, v2.table_name from v1
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
c table_name
tables_priv tables_priv
time_zone time_zone
time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_transition time_zone_transition
time_zone_transition_type time_zone_transition_type
t2 t2
t3 t3
t1 t1
t4 t4
select table_name from information_schema.TABLES
where table_schema = "testtets" and table_name like "t%";
table_name
t1
t4
select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets";
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
NULL testtets t1 1 testtets string_data 1 b A NULL NULL NULL YES BTREE
show keys * where TABLE_SCHEMA Like "test%";
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
NULL test t3 1 test a_data 1 a A NULL NULL NULL YES BTREE
NULL testtets t1 1 testtets string_data 1 b A NULL NULL NULL YES BTREE
show keys where INDEX_NAME = "a_data";
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t3 1 a_data 1 a A NULL NULL NULL YES BTREE
show tables like 't%';
Tables_in_test (t%)
t2
t3
show tables * from test where table_name like 't%';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
NULL test t2
NULL test t3
show table status;
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
t2 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL
t3 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL
v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
show full columns from t3 like "a%";
Field Type Collation Null Key Default Extra Privileges Comment
a int(11) NULL YES MUL NULL select,insert,update,references
show full columns from mysql.db like "Insert%";
Field Type Collation Null Key Default Extra Privileges Comment
Insert_priv enum('N','Y') utf8_bin N select,insert,update,references
show full columns from v1;
Field Type Collation Null Key Default Extra Privileges Comment
c char(64) latin1_swedish_ci select,insert,update,references
select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a";
2004-11-15 17:20:45 +01:00
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME TYPE COLLATION_NAME IS_NULLABLE KEY COLUMN_DEFAULT EXTRA PRIVILEGES COMMENT
NULL testtets t1 a 1 int 0 11 4 0 NULL int(11) NULL YES NULL select,insert,update,references
show columns * where table_name = "t1";
2004-11-15 17:20:45 +01:00
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME TYPE COLLATION_NAME IS_NULLABLE KEY COLUMN_DEFAULT EXTRA PRIVILEGES COMMENT
2004-11-15 22:29:49 +01:00
NULL testtets t1 a 1 int 0 11 4 0 NULL int(11) NULL YES NULL select,insert,update,references
NULL testtets t1 b 2 varchar 30 30 30 31 latin1 varchar(30) latin1_swedish_ci YES MUL NULL select,insert,update,references
drop view v1;
drop tables testtets.t4, testtets.t1, t2, t3;
drop database testtets;
select * from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like 'latin1%';
CHARACTER_SET_NAME Description DEFAULT_COLLATE_NAME Maxlen
latin1 ISO 8859-1 West European latin1_swedish_ci 1
SHOW CHARACTER SET LIKE 'latin1%';
Charset Description Default collation Maxlen
latin1 ISO 8859-1 West European latin1_swedish_ci 1
SHOW CHARACTER SET * LIKE 'latin1%';
CHARACTER_SET_NAME Description DEFAULT_COLLATE_NAME Maxlen
latin1 ISO 8859-1 West European latin1_swedish_ci 1
SHOW CHARACTER SET WHERE CHARACTER_SET_NAME like 'latin1%';
Charset Description Default collation Maxlen
latin1 ISO 8859-1 West European latin1_swedish_ci 1
SHOW CHARACTER SET CHARACTER_SET_NAME WHERE CHARACTER_SET_NAME like 'latin1%';
CHARACTER_SET_NAME
latin1
SHOW CHARACTER SET * WHERE CHARACTER_SET_NAME like 'latin1%';
CHARACTER_SET_NAME Description DEFAULT_COLLATE_NAME Maxlen
latin1 ISO 8859-1 West European latin1_swedish_ci 1
select * from information_schema.COLLATIONS
where COLLATION_NAME like 'latin1%';
COLLATION_NAME Charset Id Default Compiled Sortlen
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
SHOW COLLATION LIKE 'latin1%';
Collation Charset Id Default Compiled Sortlen
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
SHOW COLLATION * LIKE 'latin1%';
COLLATION_NAME Charset Id Default Compiled Sortlen
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
SHOW COLLATION WHERE COLLATION_NAME like 'latin1%';
Collation Charset Id Default Compiled Sortlen
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
SHOW COLLATION COLLATION_NAME WHERE COLLATION_NAME like 'latin1%';
COLLATION_NAME
latin1_german1_ci
latin1_swedish_ci
latin1_danish_ci
latin1_german2_ci
latin1_bin
latin1_general_ci
latin1_general_cs
latin1_spanish_ci
SHOW COLLATION * WHERE COLLATION_NAME like 'latin1%';
COLLATION_NAME Charset Id Default Compiled Sortlen
latin1_german1_ci latin1 5 0
latin1_swedish_ci latin1 8 Yes Yes 1
latin1_danish_ci latin1 15 0
latin1_german2_ci latin1 31 Yes 2
latin1_bin latin1 47 Yes 1
latin1_general_ci latin1 48 0
latin1_general_cs latin1 49 0
latin1_spanish_ci latin1 94 0
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY
where COLLATION_NAME like 'latin1%';
COLLATION_NAME CHARACTER_SET_NAME
latin1_german1_ci latin1
latin1_swedish_ci latin1
latin1_danish_ci latin1
latin1_german2_ci latin1
latin1_bin latin1
latin1_general_ci latin1
latin1_general_cs latin1
latin1_spanish_ci latin1
create function sub1(i int) returns int
return i+1;
create procedure sel2()
begin
select * from t1;
select * from t2;
end|
show procedure status;
Db Name Type Definer Modified Created Security_type Comment
test sel2 PROCEDURE root@localhost # # DEFINER
show function status;
Db Name Type Definer Modified Created Security_type Comment
test sub1 FUNCTION root@localhost # # DEFINER
select a.ROUTINE_NAME from information_schema.ROUTINES a,
information_schema.SCHEMATA b where
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
ROUTINE_NAME
sel2
sub1
explain select a.ROUTINE_NAME from information_schema.ROUTINES a,
information_schema.SCHEMATA b where
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE # ALL NULL NULL NULL NULL 2
1 SIMPLE # ALL NULL NULL NULL NULL 2 Using where
select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a,
mysql.proc b where a.ROUTINE_NAME = b.name;
ROUTINE_NAME name
sub1 sub1
sel2 sel2
select count(*) from information_schema.ROUTINES;
count(*)
2
create view v0 (c) as select schema_name from information_schema.SCHEMATA;
select * from v0;
c
mysql
test
explain select * from v0;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY # ALL NULL NULL NULL NULL 2
create view v1 (c) as select table_name from information_schema.TABLES
where table_name="v1";
select * from v1;
c
v1
create view v2 (c) as select column_name from information_schema.COLUMNS
where table_name="v2";
select * from v2;
c
c
create view v3 (c) as select CHARACTER_SET_NAME from information_schema.CHARACTER_SETS
where CHARACTER_SET_NAME like "latin1%";
select * from v3;
c
latin1
create view v4 (c) as select COLLATION_NAME from information_schema.COLLATIONS
where COLLATION_NAME like "latin1%";
select * from v4;
c
latin1_german1_ci
latin1_swedish_ci
latin1_danish_ci
latin1_german2_ci
latin1_bin
latin1_general_ci
latin1_general_cs
latin1_spanish_ci
show keys from v4;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.VIEWS where TABLE_NAME like "v%";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE
NULL test v0 select `SCHEMATA`.`SCHEMA_NAME` AS `c` from `information_schema`.`SCHEMATA` NONE NO
NULL test v1 select `TABLES`.`TABLE_NAME` AS `c` from `information_schema`.`TABLES` where (`TABLES`.`TABLE_NAME` = _latin1'v1') NONE NO
NULL test v2 select `COLUMNS`.`COLUMN_NAME` AS `c` from `information_schema`.`COLUMNS` where (`COLUMNS`.`TABLE_NAME` = _latin1'v2') NONE NO
NULL test v3 select `CHARACTER_SETS`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`CHARACTER_SETS` where (`CHARACTER_SETS`.`CHARACTER_SET_NAME` like _latin1'latin1%') NONE NO
NULL test v4 select `COLLATIONS`.`COLLATION_NAME` AS `c` from `information_schema`.`COLLATIONS` where (`COLLATIONS`.`COLLATION_NAME` like _latin1'latin1%') NONE NO
drop view v0, v1, v2, v3, v4;
create table t1 (a int);
grant select,update,insert on t1 to mysqltest_1@localhost;
grant select (a), update (a),insert(a), references(a) on t1 to mysqltest_1@localhost;
grant all on test.* to mysqltest_1@localhost with grant option;
select * from information_schema.USER_PRIVILEGES where grantee like '%mysqltest_1%';
GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_1'@'localhost' NULL USAGE NO
select * from information_schema.SCHEMA_PRIVILEGES where grantee like '%mysqltest_1%';
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_1'@'localhost' NULL test SELECT YES
'mysqltest_1'@'localhost' NULL test INSERT YES
'mysqltest_1'@'localhost' NULL test UPDATE YES
'mysqltest_1'@'localhost' NULL test DELETE YES
'mysqltest_1'@'localhost' NULL test CREATE YES
'mysqltest_1'@'localhost' NULL test DROP YES
'mysqltest_1'@'localhost' NULL test REFERENCES YES
'mysqltest_1'@'localhost' NULL test INDEX YES
'mysqltest_1'@'localhost' NULL test ALTER YES
'mysqltest_1'@'localhost' NULL test CREATE TEMPORARY TABLES YES
'mysqltest_1'@'localhost' NULL test LOCK TABLES YES
'mysqltest_1'@'localhost' NULL test CREATE VIEW YES
'mysqltest_1'@'localhost' NULL test SHOW VIEW YES
select * from information_schema.TABLE_PRIVILEGES where grantee like '%mysqltest_1%';
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_1'@'localhost' NULL test t1 SELECT NO
'mysqltest_1'@'localhost' NULL test t1 INSERT NO
'mysqltest_1'@'localhost' NULL test t1 UPDATE NO
select * from information_schema.COLUMN_PRIVILEGES where grantee like '%mysqltest_1%';
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_1'@'localhost' NULL test t1 a SELECT NO
'mysqltest_1'@'localhost' NULL test t1 a INSERT NO
'mysqltest_1'@'localhost' NULL test t1 a UPDATE NO
'mysqltest_1'@'localhost' NULL test t1 a REFERENCES NO
delete from mysql.user where user='mysqltest_1';
delete from mysql.db where user='mysqltest_1';
delete from mysql.tables_priv where user='mysqltest_1';
delete from mysql.columns_priv where user='mysqltest_1';
flush privileges;
drop table t1;
create table t1 (a int null, primary key(a));
alter table t1 add constraint constraint_1 unique (a);
alter table t1 add constraint unique key_1(a);
alter table t1 add constraint constraint_2 unique key_2(a);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
PRIMARY KEY (`a`),
UNIQUE KEY `constraint_1` (`a`),
UNIQUE KEY `key_1` (`a`),
UNIQUE KEY `key_2` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE CONSTRAINT_METHOD
2004-11-15 17:20:45 +01:00
NULL test PRIMARY test t1 PRIMARY KEY NULL
NULL test constraint_1 test t1 UNIQUE NULL
NULL test key_1 test t1 UNIQUE NULL
NULL test key_2 test t1 UNIQUE NULL
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
NULL test PRIMARY test t1 a 1 NULL NULL NULL
NULL test constraint_1 test t1 a 1 NULL NULL NULL
NULL test key_1 test t1 a 1 NULL NULL NULL
NULL test key_2 test t1 a 1 NULL NULL NULL
drop table t1;
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id),
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE CONSTRAINT_METHOD
2004-11-15 17:20:45 +01:00
NULL test PRIMARY test t1 PRIMARY KEY NULL
NULL test PRIMARY test t2 PRIMARY KEY NULL
NULL test t2_ibfk_1 test t2 FOREIGN KEY ON DELETE CASCADE
NULL test t2_ibfk_2 test t2 FOREIGN KEY ON UPDATE CASCADE
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
NULL test PRIMARY test t1 id 1 NULL NULL NULL
NULL test PRIMARY test t2 id 1 NULL NULL NULL
NULL test t2_ibfk_1 test t2 t1_id 1 test t1 id
NULL test t2_ibfk_2 test t2 t1_id 1 test t1 id
select table_name from information_schema.TABLES where table_schema like "test%";
table_name
t1
t2
select table_name,column_name from information_schema.COLUMNS where table_schema like "test%";
table_name column_name
t1 id
t2 id
t2 t1_id
select ROUTINE_NAME from information_schema.ROUTINES;
ROUTINE_NAME
sel2
sub1
delete from mysql.user where user='mysqltest_1';
drop table t2;
drop table t1;
drop procedure sel2;
drop function sub1;
2004-11-15 17:20:45 +01:00
create table t1(a int);
create view v1 (c) as select a from t1 with check option;
create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION;
create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;
select * from information_schema.views;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE
NULL test v1 select `test`.`t1`.`a` AS `c` from `test`.`t1` WITH CASCADED CHECK OPTION YES
NULL test v2 select `test`.`t1`.`a` AS `c` from `test`.`t1` WITH LOCAL CHECK OPTION YES
NULL test v3 select `test`.`t1`.`a` AS `c` from `test`.`t1` WITH CASCADED CHECK OPTION YES
grant select (a) on test.t1 to joe@localhost with grant option;
select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'joe'@'localhost' NULL test t1 a SELECT YES
select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'joe'@'localhost' NULL test t1 USAGE YES
drop view v1, v2, v3;
drop table t1;
delete from mysql.user where user='joe';
delete from mysql.db where user='joe';
delete from mysql.tables_priv where user='joe';
delete from mysql.columns_priv where user='joe';
flush privileges;
create procedure px5 ()
begin
declare v int;
declare c cursor for select version from
information_schema.tables;
open c;
fetch c into v;
select v;
close c;
end;//
call px5()//
v
9
call px5()//
v
9