SQL Server review notes 02

Source: Internet
Author: User
/* 3. The default value is different from the default value. It can be defined once or multiple times on one or more columns of the table, it can also be applied to user-defined data types, and the default value is a database object. */-- create default Mr _ pricing as 100 -- you can see the Mr _ pricing table in the programmable --> default value -- bind the created default to Exec sp_bindefault In the table mr _ pricing, 'book1. pricing '-- result: the default value is bound to the column. -- Insert data to see how: insert into book1 (number, ibsn, title) values ('20170101', '20160301', 'javaProgramDesign ')/* Result: No. ibsn title pricing press publication date 101186 186 Java program design 100.00nullnull */-- 4, rule. it corresponds to check, especially the default and default, but it is not fixed in a column, but after it is created, specify the valid values of the inserted Table column -- create rule GZ _ pricing as @ pricing> 0 and @ pricing <10000 -- bind rule exec sp_bindrule GZ _ pricing, 'book1. pricing '-- result: the rule is bound to the column of the table. -- Insert data to see the result insert into book1 values ('20160301', '20160301', 'SQL database', 101172, 'Sun Yat-sen University', '03-13-2008 ') -- full table structure insert/* message 513, level 16, status 0, 1st row and column insertion or update conflict with the rule specified by the previous create rule statement. The statement has been terminated. The conflict occurs in the database 'book', the table 'dbo. book1', and the column 'price '. The statement has been terminated. */

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.