Querying all tables in a database using SQL statements

Source: Internet
Author: User

Oracle:

SELECT *  from tables with permissions in the all_tables;--system SELECT *  from dba_tables;--system table SELECT *  from user_tables;--the table under the current user

SQL Server

1, using the sysobjects system table in this table, each object created in the database (for example, constraints, defaults, logs, rules, and stored procedures) has a row, and we filter out all the records in the table that are xtype equals u, which is the table in the database. The example statements are as follows:

SELECT * from sysobjects where xtype= ' U '

Note: In SQL SERVER2005, the sys.objects catalog view appears in place of the sysobjects system table, and in SQL SERVER2005 and later versions, You can query all tables using sysobjects system tables and any object in the Sys.objects catalog view.

2, use the Sys.tables catalog view sys.tables catalog view to return one row for each Table object. The example statements are as follows:

SELECT * FROM Sys.tables

Note: The Sys.tables catalog view is also available only in SQL SERVER2005 and later versions.

3, using stored procedures sp_tables sp_tables stored procedures, you can return a list of objects that can be queried in the current environment. This represents any object that can appear in the FROM clause. We can execute the following statement:

EXEC sp_tables

It is the table information that filters out all records that table_type equals table in the result set.

http://blog.csdn.net/Fuyouche/article/details/8039197

Querying all tables in a database using SQL 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.