CREATE TABLE statement
476
CREATE TABLE library_books (
-- NOT NULL is assumed for primary key columns
isbn CHAR(20)
copyright_date
title
author
-- column(s) corresponding to primary key of room
-- are created automatically
FOREIGN KEY location REFERENCES room
)
♦
Create a table for a library database to hold information on borrowed
books.
CREATE TABLE borrowed_book (
-- Default on insert is that book is borrowed today
-- date_borrowed DATE NOT NULL DEFAULT CURRENT DATE,
-- date_returned will be NULL until the book is
-- returned
date_returned
book
-- The check condition is UNKNOWN until
-- the book is returned, which is allowed
CHECK( date_returned >= date_borrowed )
)
♦
Create tables for a sales database to hold order and order item
information.
CREATE TABLE Orders (
order_num INTEGER NOT NULL PRIMARY KEY,
date_ordered DATE,
name CHAR(80)
);
CREATE TABLE Order_item (
order_num
item_num
PRIMARY KEY (order_num, item_num),
-- When an order is deleted, delete all of its
-- items.
FOREIGN KEY (order_num)
REFERENCES Orders (order_num)
ON DELETE CASCADE
)
♦
Creates a table named
proxy table named
t1
CREATE TABLE t1
( a
INT,
b
CHAR(10))
AT 'SERVER_A.db1.joe.t1'
PRIMARY KEY,
DATE,
CHAR(100),
CHAR(50),
DATE,
CHAR(20)
REFERENCES library_books (isbn),
INTEGER NOT NULL,
SMALLINT NOT NULL,
t1
at the remote server
SERVER_A
that is mapped to the remote table.
and creates a
Need help?
Do you have a question about the Adaptive Server Anywhere and is the answer not in the manual?
Questions and answers