Get available database and their information:
select * from INFORMATION_SCHEMA.SCHEMATA; Result Set Columns:
Get available table names from a database:
select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='test_db';
Result Set Columns:
select COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLUMN_KEY, EXTRA from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA='test_db' and TABLE_NAME='user_profile';
select * from INFORMATION_SCHEMA.SCHEMATA; Result Set Columns:
- CATALOG_NAME
- SCHEMA_NAME
- DEFAULT_CHARACTER_SET_NAME
- DEFAULT_COLLATION_NAME
- SQL_PATH
Get available table names from a database:
select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='test_db';
Result Set Columns:
- TABLE_NAME contains the table name
select COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, COLUMN_KEY, EXTRA from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA='test_db' and TABLE_NAME='user_profile';
If you want checkout INFORMATION_SCHEMA database inside MySql for more.
No comments:
Post a Comment