Skip to content

Instantly share code, notes, and snippets.

@nisar1
Last active August 29, 2015 13:57
Show Gist options
  • Save nisar1/9426905 to your computer and use it in GitHub Desktop.
Save nisar1/9426905 to your computer and use it in GitHub Desktop.
defination of database objects.
-- Lists sp,tbl,fn in a dbz
--show procedure
SHOW PROCEDURE STATUS WHERE Db = DATABASE() AND TYPE = 'PROCEDURE';
SHOW FUNCTION STATUS WHERE Db = DATABASE() ;
select name from mysql.proc where db = database();
--list keys
select *
from INFORMATION_SCHEMA.TABLE_CONSTRAINTS
where CONSTRAINT_TYPE = 'FOREIGN KEY'
-- show create statement
SHOW CREATE PROCEDURE procedurename ;
SHOW CREATE TABLE tablename;
SHOW TABLE STATUS ;
-- get column details
DESCRIBE 'table name' ;
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'table_name' and table_schema = 'database' ;
SHOW COLUMNS FROM table_name ;
-- get table details
SELECT table_name FROM information_schema.tables WHERE table_schema = 'db_sanitary2' ;
-------
show databases;
show tables;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment