SQL Server creation and deletion Constraints

Source: Internet
Author: User
Use SQL statements to create and delete Constraints

Primary constraints: (primary key constraint); unique constraints: (unique constraint); check constraints: (check constraint); default constraints: (default constraint); external constraints: (foreign key constraint ); **************************************** * ***************************** add constraints: alter table tablenameadd constraint pk_colname primary key (colname) primary constraint alter table tablenameadd constraint uq_colname unique (colname) unique constraint alter table tablenameadd constraint df_colname default ('address unknown ') for colname default constraint alter table tablenameadd constraint ck_colname check (colname between 12 and 15) Check constraint alter table tablenameadd constraint fk_colname foreign key (colname) References tablename (colname) external constraint delete: alter table tablenameddrop constraint name create login account/database user create login account: exec sp_grantlogin 'windows domain name/domain account' Create Database User: exec sp_grantdbaccess' login account ', 'database user' authorization to database: grant permission [on table name] to database user the above statements can be directly operated on Enterprise Manager/security/login/New login in Enterprise Manager
Enter the name and password
Select database access, and then check "db_owner allowed in" database role"
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.