Manipulating data with SQL statements

Source: Internet
Author: User

I. Completeness: reliability + accuracy = data integrity
Ensure data integrity = enforce integrity constraints 1. Entity integrity: Entity integrity constraint row (record), which specifies that duplicate data cannot appear in the table 2. Domain integrity: Domain integrity constraint column (field), which specifies that the field data in the table is formatted correctly 3. Referential integrity: Referential integrity constraint table-to-table relationships, Cannot exist table-to-table data 4. Custom Integrity: Custom integrity constraints to constrain user-defined triggers
Two. Create a database table 1. Data type
Binary data types store non-character and text data images that can be used to store an image
Text data type character data includes any combination of letters, symbols, or numeric characters char fixed-length non-Unicode character data
varchar variable-length non-Unicode data
NChar fixed-length Unicode data
Nvarchar variable-length Unicode data
Text Store long text information
ntext storing long text with variable length
Date and time date and time datetime
Numeric data This data contains only numbers, including integers and floating-point int, smallint integers
float, real floating-point number
Currency data type Decimal currency value money
Bit data type indicates yes/No data bit store Boolean data type
2. Primary key primary key as a unique identifier in the table that identifies this column does not allow duplicate data
If two or more columns are combined to uniquely identify each row in the table, the primary key is called the "composite primary key" principle of selecting the primary key
Minimum sex
Try selecting a single key as the primary key
Stability
Try selecting a column with fewer values to update as the primary key
3. Default setting column default value if this column must be allowed to be empty, otherwise the set default value is invalid
If this column is not entered when inserting data or changing data, then the default value is bound to 4. The identity column sets the identity column that you want to set as the primary key, guarantees that the data type of this column is int, and then the identity specification for this column is changed to Yes, the identity seed represents a few 5 increments from the beginning. Create primary foreign key table Brahma key table 6. Considerations for the primary key table month foreign key table
You cannot add records to a child table when there are no corresponding records in the primary table
No school numbers that do not exist in the Student information table can be found in the score table
You cannot change the values in the primary table and cause the records in the child table to be orphaned
Change the number of students in the Student information table, and the student's score list should be changed as well.
The child table has a record corresponding to the primary table, and the row cannot be deleted from the primary table
You can't delete a student who has a score.
Delete the primary table before deleting the child table
Delete the student's information form after deleting the student's score form first

Manipulating data with 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.