TAILIEUCHUNG - SQL VISUAL QUICKSTART GUIDE- P39

SQL VISUAL QUICKSTART GUIDE- P39:SQL (pronounced es-kyoo-el) is the standard programming language for creating, updating, and retrieving information that is stored in databases. With SQL, you can turn your ordinary questions (“Where do our customers live?”) into statements that your database system can understand (SELECT DISTINCT city, state FROM customers;) | Chapter 11 Forcing Unique Values with UNIQUE To specify a simple unique constraint To specify a simple unique constraint as a column constraint add the following column constraint to a CREATE TABLE column definition CONSTRAINT constraint_name UNIQUE or To specify a simple unique constraint as a table constraint add the following table constraint to a CREATE TABLE definition CONSTRAINT constraint_name UNIQUE unique_column unique_column is the name of the column that forbids duplicate values. Zero or more UNIQUE constraints are allowed in a table. For the general syntax of CREATE TABLE see Creating Tables earlier in this chapter. The CONSTRAINT clause is optional and constraint_name is the name of the unique constraint see Understanding Constraints earlier in this chapter. Listings and show two equivalent ways to define a simple unique constraint for the sample-database table titles. Listing uses a column constraint to designate a unique column. This syntax shows the easiest way to create a simple unique constraint. Listing uses a named table constraint to specify a unique column. This syntax shows the preferred way to add a unique constraint you can use the name if you decide to change or delete the constraint later. See Altering a Table with ALTER TABLE later in this chapter. Listing Define a simple unique constraint on the column title_name for the sample-database table titles by using a column constraint. Listing CREATE TABLE titles title_id CHAR 3 PRIMARY KEY title_name VARCHAR 40 NOT NULL UNIQUE type VARCHAR 10 pub_id CHAR 3 NOT NULL pages INTEGER price DECIMAL 5 2 sales INTEGER pubdate DATE contract SMALLINT NOT NULL Listing Define a simple unique constraint on the column title_name for the sample-database table titles by using a named table constraint. Listing CREATE TABLE titles title_id CHAR 3 NOT NULL title_name VARCHAR 40 NOT NULL type VARCHAR 10 pub_id CHAR 3 NOT NULL pages INTEGER price DECIMAL 5 2 sales INTEGER

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.