tailieunhanh - Microsoft SQL Server 2008 R2 Unleashed- P90

Microsoft SQL Server 2008 R2 Unleashed- P90:SQL Server 2005 provided a number of significant new features and enhancements over what was available in SQL Server 2000. This is not too surprising considering there was a five-year gap between these major SQL Server 2008 is not as much of a quantum leap forward from SQL Server 2005 | 834 CHAPTER 26 Implementing Data Integrity tmstmp timestamp NOT NULL password char 13 NOT NULL DEFAULT defaultpw1 Shortdesc VARCHAR 50 NULL The table in this example has a unique characteristic each column has some sort of default value associated with it. One column has a default of NULL because it is nullable. The IDENTITY and TIMESTAMP columns automatically generate values because of their data type and the password column has an explicit default definition. In this scenario you can supply the keywords DEFAULT VALUES in the INSERT statement to insert a row of data as shown in the following example INSERT test_default DEFAULT VALUES select from test_default results from previous select statement id tmstmp password Shortdesc . - - 1 0X00000000000007D1 defaultpw NULL You can see from the results of the SELECT statement in this example that a row was inserted in the new table and this row includes default values for all the columns. If you want to supply values for some of the columns and allow the defaults to be used for other columns you can simply exclude the columns with defaults from the column listing in the INSERT statement. The following example demonstrates how to do this INSERT test_default ShortDesc VALUES test default insertion SELECT FROM test_default where ShortDesc test default insertion results from previous select statement id tmstmp password Shortdesc 2 0X00000000000007D2 defaultpw test default insertion The DEFAULT keyword can also be listed explicitly in the VALUE listing of the INSERT statement as shown in the following example INSERT test_default tmstmp password ShortDesc VALUES DEFAULT DEFAULT DEFAULT SELECT FROM test_default where id @@identity 1 row s affected id tmstmp password Shortdesc 3 0X00000000000007D5 defaultpw NULL Download from Defaults 835 All the examples so far have dealt with INSERT statements but there is one scenario in which a default value can be applied with an UPDATE statement. This scenario is similar to

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.