EasyManua.ls Logo

Sybase Adaptive Server Anywhere - Page 494

Sybase Adaptive Server Anywhere
1182 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CREATE TABLE statement
476
CREATE TABLE library_books (
-- NOT NULL is assumed for primary key columns
isbn CHAR(20) PRIMARY KEY,
copyright_date DATE,
title CHAR(100),
author CHAR(50),
-- 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 DATE,
book CHAR(20)
REFERENCES library_books (isbn),
-- 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 INTEGER NOT NULL,
item_num SMALLINT NOT NULL,
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
t1
at the remote server
SERVER_A
and creates a
proxy table named
t1
that is mapped to the remote table.
CREATE TABLE t1
( a INT,
b CHAR(10))
AT ’SERVER_A.db1.joe.t1’

Table of Contents

Related product manuals