在对数据进行管理时,除了使用SSMS之外,还可以使用T-SQL语言进行数据的管理和维护。接下来,为大家介绍T-SQL语法的语法结构与使用。
First, T-SQL
1, T-SQL composition
DML: Used to query, insert, delete, and modify data in a database
DDL: Used to build a database and define its columns
DCL: Used to control access permissions for database components
Second, query data using T-SQL
1. T-SQL syntax structure
SELECT < column names > from < table names > WHERE < query constraints >
(1) Querying all columns in a table
SELECT from table_name ( representing all columns)
For example: Query Student table Secondary School information
SELECT * FROM table_name
(2) Querying a specific column in a table
SELECT column_name__1,column_name_2,....... From table_name
For example: Query the class and grade of the name in the student table
SELECT name, class, score from student
(3) Querying a specific row in a table-conditional query
SELECT select_list from table_name WHERE search_conditions
(4) The number of rows that the query returns limits
SELECT TOP n select_list from table_name
T-SQL 中的查询基本格式是有SELECT子句、FROM子句、和WHERE 子句组成的查询块。
T-SQL query statements