SQL Server 7.0 (1)

Source: Internet
Author: User
Tags sql server query
Interactive SQL (Transact SQL, TSQL)
It is the query language of SQL Server. Run the following command:
· Create and database objects.
· Access and modify data.
· Aggregation, also known as aggregation ).
· Implement security measures.
Database objects
A database object is a physical object in a database. These objects have unique names and save data and data relationship information. SQL Server defines the following objects:
1. table)
A table is a two-dimensional array used to store data. It has rows and columns. A column is also called a table attribute or field. Each column in a table has a unique name, and each column contains a specific data type, which is defined by the data type in the column.
2. view)
A view is a virtual table that only contains a part of the table. Unlike a table, the data stored in a view is not physically stored data. It is derived from a table. A derived table is called a basic table of a view. The view definition is stored in the database.
3. Constraints (constraint)
Constraints define data integrity and validity. The constraint is to create rules for values in the column. In other words, if an end condition is defined in a column, each value inserted in this column needs to pass the constraints check. A constraint is a better choice for ensuring data integrity and validity on triggers and rules. SQL Server Query Optimizer uses constraints to generate a low-cost Query plan. The constraints are as follows:
· Not null: the constraint condition requires that the column cannot contain NULL values.
· CHECK checks constraints after specifying a set of values that can be owned by a column. Any data out of the definition in the column is invalid. A set of valid values is called a column field.
· Primary key is a combination of columns or columns, which uniquely identifies a row.
· Foreign key is used to define the parent-child relationship between two tables. If a keyword is both a part of a table's primary keywords and a master keyword of another table, it is called a foreign keyword. External keywords are used to define the integrity of data references.
The UNIQUE constraint for UNIQUE is that no two rows have the same NON-NULL value in the column. Uniqueness is guaranteed by the primary keyword, but they do not allow NULL values, and each table can only have one keyword.
4. default value)
The default value is the value defined by the column. If the value of a column is not provided when a row is inserted, the default value is used for this column. The default value can be one of the following:
· Constant
· Mathematical expressions
· Internal function (Built-in function)
5. Rules (rule)
The rule execution function is the same as the CHECK constraint. However, different rules and constraints are: rules exist as independent objects and can be used for multiple tables, while constraints are stored as part of the table. However, rules are provided as backward compatibility. We recommend that you use constraints.
Related Article

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.