Database Review Summary (7)-creation of tables and insertion of commands, data modification, data deletion

Source: Internet
Author: User

One, the operation of the table

Tables: creating, modifying, deleting

all existing tables can be viewed through the select * from sysobjects where xtype= ' U '

Use commas to separate multiple columns

PRIMARY key:primary key

non-empty: notnull

Unique :unique

defaults: Default()

checking:check ()

foreign key:foreign KEY ( column name ) references table name ( column name )

For example:--Create a table

Use practicedbcreate table ClassInfo (CIdintNotNULLPrimary Key Identity (1,1), Ctitle nvarchar) CREATE table studentinfo (SIdintNotNULLPrimary Key Identity (1,1), SName nvarchar (Ten) notNULL, Sgender bitdefault(0), Sbirthday date, SphoneChar( One), Semail varchar ( -), CidintNotNULL, foreign KEY (CID) references ClassInfo (CID))

Second, the operation of the table data

-"Simple query: SELECT * FROM table name"
-"Add data: INSERT into table name (column name) values (value)
Illustration 1: The column name of the required value corresponds to the position of the value
Note 2: You can omit the column name section if all the more values are inserted
Extensions: Add multiple lines at once, and you can stitch multiple data directly behind the values, separated by commas
-"Modify data: Update table name set column name 1= value 1, column name 2= value 2 ... where ...
-delete data: Delete from table name where ...
Empty: TRUNCATE TABLE name
Description: The FROM keyword can be omitted without writing
Typically implemented: tombstone, physical Delete

Database Review Summary (7)-creation of tables and insertion of commands, data modification, data deletion

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.