Study site: http://www.w3cschool.cc/sql/sql-tutorial.html One: Querying the properties of all tables
SELECT 'ALTER TABLE'+ Case wheno.schema_id is not NULL Then(SELECTNAME+'.' fromSys.schemasWHEREschema_id=O.SCHEMA_ID)ELSE "' END +object_name(parent_object_id)+'DROP CONSTRAINT'+object_name(object_id)+': On UPDATE cascade on DELETE Cascade' fromSys.objects asOJOINSys.schemas asS ono.schema_id=s.schema_idWHEREO.typeinch('C','D','F','UQ') SELECT * frominformation_schema. Table_constraintswheretable_nameinch(' Book','Borrow','Reader')--object_id (Object_name,object_type)--Object Type:--AF = aggregate function (CLR)--C = Check constraint--D = DEFAULT (constrained or standalone)--F = FOREIGN key constraint--FN = SQL scalar function--FS = Scalar function of the General Assembly (CLR)--FT = assembly (CLR) Table-valued function--IF = SQL Inline table-valued function--IT = Internal table--P = SQL stored Procedure--PC Assembly (CLR) stored Procedures--PG = plan guide www.2cto.com--PK = PRIMARY key constraint--R = Rule (Legacy, standalone)--RF = replication filtering process--S = System base Table--SN = synonym--SQ = Service queue--TA = component (CLR) DML trigger--TF = SQL table-valued function--TR = SQL DML trigger--TT = Table Type--U = table (user defined)--UQ = Unique constraint--V = View--X = extended stored Procedure
II: Classic SQL statement Daquan
Original: http://www.cnblogs.com/yubinfeng/archive/2010/11/02/1867386.html
Three: Query which tables appear in a field
SELECT * from Information_schema. COLUMNS WHERE column_name='rankname'
Some common SQL query statements