阅读量:0
MySQL中显示数据库属性值的查询语句 1. 显示所有数据库的名称及其字符集和排序规则 SELECT SCHEMA_NAME AS Database_Name, DEFAULT_COLLATION_NAME AS Collation, DEFAULT_CHARACTER_SET_NAME AS Character_Set FROM INFORMATION_SCHEMA.SCHEMATA; 2. 显示当前数据库的属性值 SELECT SCHEMA_NAME AS Database_Name, DEFAULT_COLLATION_NAME AS Collation, DEFAULT_CHARACTER_SET_NAME AS Character_Set FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = DATABASE(); 3. 显示所有表的属性值 SELECT TABLE_SCHEMA AS Database_Name, TABLE_NAME, TABLE_TYPE, ENGINE, TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE(); 4. 显示当前表的所有列的属性值 SELECT TABLE_SCHEMA AS Database_Name, TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_DEFAULT, IS_NULLABLE, COLUMN_TYPE, COLUMN_KEY, EXTRA FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'your_table_name'; 替换 'your_table_name' 为你想要查询的表名
SQL语句分别用于查询数据库的名称、字符集、排序规则,以及表的名称、类型、引擎、列属性等信息,请根据实际需要替换查询中的表名和数据库。