标签:orm proc code metadata nts ima trigger files order by
MySQL:
use sakila; -- show fields from table_name; -- show keys from table_name; SELECT `REFERENCED_TABLE_NAME` FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_NAME` = ‘[table_containing_foreign_key]‘ AND `COLUMN_NAME` = ‘[foreign_key]‘; SHOW COLUMNS FROM City; select * from information_schema.tables; select * from information_schema.tables where table_schema=‘sakila‘; select * from information_schema.tables; select * from information_schema.KEY_COLUMN_USAGE; select * from information_schema.PARAMETERS; select * from information_schema.VIEWS; select * from information_schema.TRIGGERS; -- get Table/Fields metadata SELECT table_schema, table_name, column_name, ordinal_position, data_type, numeric_precision, column_type, column_default, is_nullable, column_comment FROM information_schema.columns -- WHERE (table_schema=‘sakila‘ and table_name = ‘city‘) -- 显示指定表 WHERE table_schema=‘sakila‘ order by ordinal_position; -- get Foregn Keys referenced table SELECT `REFERENCED_TABLE_NAME` FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_NAME` = ‘city‘; -- `TABLE_NAME` = ‘table_name‘ AND -- `COLUMN_NAME` = ‘Column_Name‘ -- get indexes (primary and foreign) for a table -- get All indexes and referreced table SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_NAME` = ‘city‘ AND `TABLE_SCHEMA` = ‘sakila‘; SELECT * FROM `information_schema`.`REFERENTIAL_CONSTRAINTS` WHERE `TABLE_NAME` = ‘city‘ AND `CONSTRAINT_SCHEMA` = ‘sakila‘; -- get STORED PROCEDURES SELECT * FROM `information_schema`.`ROUTINES` WHERE `ROUTINE_SCHEMA` = ‘sakila‘; -- get TRIGGERS SELECT * FROM `information_schema`.`TRIGGERS` WHERE `TRIGGER_SCHEMA` = ‘sakila‘; -- get EVENTS SELECT * FROM `information_schema`.`EVENTS` WHERE `EVENT_SCHEMA` = ‘sakila‘; -- get VIEWS SELECT * FROM `information_schema`.`VIEWS` WHERE `TABLE_NAME` = ‘city‘ AND `TABLE_SCHEMA` = ‘sakila‘; -- ‘COLUMNS‘ ‘EVENTS‘ ‘FILES‘ ‘TABLES‘ SELECT table_schema, table_name, column_name, ordinal_position, data_type, numeric_precision, column_type FROM information_schema.columns WHERE table_name = ‘TABLES‘;
sql server :
--SQL-92 standard select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH from DuVehicle.information_schema.columns; SELECT * FROM DuVehicle.INFORMATION_SCHEMA.PARAMETERS; GO GO /*INFORMATION_SCHEMA views: View Name Description CHECK_CONSTRAINTS Holds information about constraints in the database COLUMN_DOMAIN_USAGE Identifies which columns in which tables are user-defined datatypes COLUMN_PRIVILEGES Has one row for each column level permission granted to or by the current user COLUMNS Lists one row for each column in each table or view in the database CONSTRAINT_COLUMN_USAGE Lists one row for each column that has a constraint defined on it CONSTRAINT_TABLE_USAGE Lists one row for each table that has a constraint defined on it DOMAIN_CONSTRAINTS Lists the user-defined datatypes that have rules bound to them DOMAINS Lists the user-defined datatypes KEY_COLUMN_USAGE Lists one row for each column that‘s defined as a key PARAMETERS Lists one row for each parameter in a stored procedure or user-defined function REFERENTIAL_CONSTRAINTS Lists one row for each foreign constraint ROUTINES Lists one row for each stored procedure or user-defined function ROUTINE_COLUMNS Contains one row for each column returned by any table-valued functions SCHEMATA Contains one row for each database TABLE_CONSTRAINTS Lists one row for each constraint defined in the current database TABLE_PRIVILEGES Has one row for each table level permission granted to or by the current user TABLES Lists one row for each table or view in the current database VIEW_COLUMN_USAGE Lists one row for each column in a view including the base table of the column where possible VIEW_TABLE_USAGE Lists one row for each table used in a view VIEWS Lists one row for each view */
SQL Server Metadata Toolkit 2005 - 2014 https://sqlmetadata.codeplex.com/
MySQL and Sql Server:Getting metadata using sql script (SQL-92 standard)
标签:orm proc code metadata nts ima trigger files order by
原文地址:http://www.cnblogs.com/geovindu/p/7119796.html