TAILIEUCHUNG - MASTERING SQL SERVER 2000- P10

Tham khảo tài liệu 'mastering sql server 2000- p10', công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 420 CHAPTER 11 TABLES 4. To see the new record choose Query New Query. 5. Enter and execute the following code SELECT FROM customers 6. Notice that the record now exists with a custid of 1 that is because of the identity property discussed earlier which automatically added the number for you . 7. To test the check constraint by adding characters in the zip field choose Query New Query. 8. In the query window enter the following code and note the letters in the zip code field USE sales INSERT customers VALUES John Smith 817 3rd Chicago IL AAB1C 8015551212 9. Notice in the results pane that the query violated a constraint and so failed. RESTRICTING THE DATA 421 Another tool at your disposal for protecting against incorrect data is the rule. Rules work just like constraints validating user data before it is allowed in the table. The only difference between rules and constraints is that rules can be bound to a user-defined datatype and constraints cannot. Binding a rule will attach the rule to the datatype so that everywhere you use that datatype the rule is already in place whereas a constraint would need to be specifically applied to the column every time you used it. Let s generate a rule for your state datatype so you can see how it s done 1. Open Enterprise Manager and expand your server then databases then Sales. 2. Under Sales select Rules. 3. From the Action menu select New Rule. 4. To create a rule that will accept only 5 of the 50 state abbreviations type State in the Name box and enter the following in the Text box feel free to add your own state here if you like @state in AZ CA WY NY FL PART III Digging into SQL Server 422 CHAPTER 11 TABLES 5. Click OK to create the rule. 6. Once back at Enterprise Manager double-click the state rule to open its properties. 7. Click the Bind UDTs button to bind the new rule to the state datatype. 8. Check the Bind box next to State to bind the rule and click OK. Note that you can also bind this to a column in a table just .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.