1. query all tables in SQL:
Select TABLE_NAME FROM database name. INFORMATION_SCHEMA.TABLES Where TABLE_TYPE = 'base table' after execution, you can see the names of all tables created by yourself in the database.
2. query all tables and columns in SQL:
Select dbo. sysobjects. name as Table_name, dbo. syscolumns.
Next: T-SQL Dynamic Query (1)--IntroductionObjective:In the development of features, we often encounter scenarios such as the following: The application has a query function that allows the user to select the desired condition in many query conditions. This is also the focus of this series.But sometimes you may find th
current server are also taken into account. In most cases, the results of the execution plan produced by both methods are similar.When establishing a SQL Server Profiler trace, an event that can be collected is the Misc:execution plan. This information (in the form of text) shows the calculated row schedule that the query optimizer uses to execute the query.You
SQL query statement "3": Multi-Table query (also called connection query, which is a connection query based on two tables)If a query needs to operate on multiple tables, it is called a connection
1. Query all tables in sql:
Select table_name from database name. Information_schema. Tables Where table_type= ' BASE table ' is executed, you can see the names of all the tables in the database that belong to you
2. Query all tables and columns in sql:Select Dbo.sysobjects.name as TABLE_NAME, dbo.syscolumns.name as column_name from Dbo.syscolumns INNER JOIN
Connection Query
You can use the join operator to query multiple tables. Connection is the main feature of the relational database model and a symbol that distinguishes it from other types of database management systems.
In the relational database management system, the relationship between data does not have to be determined when a table is created, and all information about an object is often stored in a
1. query all tables in SQL:Select TABLE_NAME FROM database name. INFORMATION_SCHEMA.TABLES Where TABLE_TYPE = 'base table' after execution, you can see the names of all tables created by yourself in the database.2. query all tables and columns in SQL:Select dbo. sysobjects. name as Table_name, dbo. syscolumns. name AS Column_name FROM dbo. syscolumns inner join dbo. sysobjects ON dbo. syscolumns. id = dbo.
Label:Next: T-SQL Dynamic Query (3)--Static SQLObjective: There's a lot of talk about dynamic queries, and this article describes some of the ways to use dynamic SQL to solve dynamic queries.Why use Dynamic sql: in many projects, dynamic SQL is widely used and even misused,
T-SQL dynamic query (1) -- Introduction
Preface:
During feature development, we often encounter a scenario similar to the following: the application has a query function that allows users to select the required conditions among many query conditions. This is also the focus of this series.
But sometimes you may find
turned on, when we run the SQL statement again, the results will appear in the message view next to the result view, and one way is to use the SQL Server Profiler tool (tool-sql Server Profiler) to help us monitor the execution of executed
Grade> = 90
-- Use "logical expression" as the query condition ......
/*
Logical expressions in SQL:
Not: non
And: corresponds
Or: or
*/
Select * from Student
-- Query the student table for a 19-year-old male student.
Select * from Student where Sage = 19 and Ssex = 'male'
-- Query the student whose age is 19 or 20 in
locked NOLOCK unlocked unlocked unlocked HOLDLOCK shared share share update UPDLOCK error update update TABLOCKX error unlocked unlocked Fixed update other unlocked unlocked Unlocked update * Specifies that the NOLOCK hint will make the table specified with this hint read-only in cursor.16. Use Profiler to track queries, get the time needed to query, find out the problem of
Tags: SQL statement electronic win style SPAN different statement column DTS --Connect remote SQL or insert data with OPENROWSET
--if only temporary access, you can directly use OPENROWSET
--Query Example
Select * from OpenRowset('SQLOLEDB'
,'SQL Server name';'User name';'Password', database name. dbo. Table name)
prompt in the SELECT statement of the cursor. Lock prompt read-only optimistic value optimistic row version control lock No prompt not locked update NOLOCK not locked HOLDLOCK sharing update UPDLOCK error Update TABLOCKX Error unlocked unlocked update other unlocked update * The specified NOLOCK prompt will make the table specified with this prompt read-only in the cursor.
16. Use Profiler to track the query
field is meaningless, with a * on the line, of course, nothing else is wrong.) )Note that although the nested SQL statement is finished parsing, but the main SQL statement is executed only once, that is, P1 points to the first record of student, P1 also point to the student table of the next record and analysis, and then into the nested SQL statement, as describ
Routine collection of commonly used SQL query statements and SQL statements
Common SQL query statements are as follows:
1. Simple query statements
1. view the table structure
SQL> DESC
How does the column selection differ when Oracle queries are converted to SQL queries? The following describes how to select columns from Oracle query to SQL query. We hope that you can have a deeper understanding of Oracle query.
When converting an Oracle
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.