|
Программирование >> Руководство по sql
ОПЕРАТОРЫ CREATE И INSERT ДЛЯ БАЗЫ ДАННЫХ BOOKBIZ Для воссоздания базы данных bookbiz вы можете использовать приведенный ниже код (для Sybase Anywhere). Мы не гарантируем его правильную работу в других версиях SQL. Для SQL Anywhere 3/1/96 */ set option date format=Minm dd yyyy hh:mmaa go set option date order = MDY go set option scale = 2 go drop table authors go create table authors (au id char(11) not null, au lname varchar(40) not null, au fname varchar(20) not null, phone char(12) null, address varchar(40) null, city varchar(20) null, state char(2) null, zip char(5) null) grant select on authors to public go drop table publishers go create table publishers (pub id char(4) not null. pub name varchar(40) null, address varchar(40) null, city varchar(20) null, state char(2) null) grant select on publishers to public go drop table roysched create table roysched (title id char(6) not null, lorange int null, hirange int null, royalty float null) grant select on roysched to public go drop table titleauthors go create table titleauthors (au id char(11) not null, title id char(6) not null, au ord tinyint null, royaltyshare float null) grant select on titleauthors to public go drop table titles go create table titles (title id char(6) not null, title varchar(80) not null, type char(12) null, pub id char(4) null, price money null, advance money null, ytd sales int null, contract bit not null, notes varchar(200) null, pubdate date null) grant select on titles to public go drop table editors go create table editors (ed id char(11) not null, ed lname varchar(40) not null, ed fname varchar(20) not null, ed pos varchar(12) null, phone char(12) null, address varchar(40) null, city varchar(20) null. state char(2) null, zip char(5) null) grant select on editors to public go drop table titleditors go create table titleditors (ed id char(11) not null, title id char(6) not null, ed ord tinyint null) grant select on titleditors to public go drop table sales go create table sales (sonum int not null, stor id char(4) not null, ponum varchar(20) not null, sdate date null) grant select on sales to public go drop table salesdetails go create table salesdetails (sonum int not null, qty ordered smallint not null, qty shipped smallint null, title id char(6) not null, date shipped date null) grant select on salesdetails to public go create unique index pubind on publishers (pub id) create unique index auidind on authors (au id) create index aunmind on authors (au lname, au fname) create unique index titleidind on titles (title id) create index titleind on titles (title) go create unique index taind on titleauthors (au id, title id)
|
© 2006 - 2024 pmbk.ru. Генерация страницы: 0.001
При копировании материалов приветствуются ссылки. |