SQL queries all tables, all columns

Source: Internet
Author: User

1. Querying all databases in an instance

Select name,database_id from sys.databases

2. Querying all tables in the database
Select Table_type,table_name from Information_schema.tables ORDER BY table_name

SELECT * from sysobjects where type= ' U ' ORDER by name (all tables)
SELECT * from sysobjects where type= ' SQ ' ORDER by name
SELECT * from sysobjects where type= ' FN ' ORDER by name
SELECT * from sysobjects where type= ' S ' ORDER by name
SELECT * from sysobjects where type= ' D ' ORDER by name
SELECT * from sysobjects where type= ' IT ' ORDER by name
SELECT * from sysobjects where type= ' F ' ORDER by name
SELECT * from sysobjects where type= ' F ' ORDER by name
SELECT * from sysobjects where type= ' PK ' ORDER by name (all primary keys)
SELECT * from sysobjects where type= ' P ' ORDER by name
SELECT * from sysobjects where type= ' TF ' ORDER by name
SELECT * from sysobjects where type= ' C ' ORDER by name
SELECT * from sysobjects where type= ' UQ ' ORDER by name
SELECT * from sysobjects where type= ' V ' ORDER by name (all views)

SQL queries all tables, all columns

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.