Some common SQL query statements

Source: Internet
Author: User
Tags scalar

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.