Implementing Constraints on Individual Columns
Following is the code for creating an Adaptive Server Anywhere version of the titles table with SQL-92 constraints. The table name is titlescnstr to avoid conflict with the titles table, which already exists in the bookbiz database. The titlescnstr definition uses the defaults and constraints shown in Figure 3.6. All of the constraints in this case apply to single columns.
SQLalter table publishers add primary key(pub_id) [command completed] create table titlescnstr (title_id char(6) not null primary key check (title_id like '[A-Z][A-Z][0-9] [0-9] [0-9][0-9]'), title varchar(80) not null unique, type char(12) default 'unclassified' null check (type in ('business', 'mod_cook', 'trad_cook', 'psychology', ...
Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.