6>
7>
8> CREATE TABLE publishers(
9> pub_id char(4) NOT NULL,
10> pub_name varchar(40) NULL,
11> city varchar(20) NULL,
12> state char(2) NULL,
13> country varchar(30) NULL DEFAULT('USA')
14> )
15> GO
1>
2>
3> insert publishers values('1', 'Publisher A', 'Vancouver', 'MA', 'USA')
4> insert publishers values('2', 'Publisher B', 'Washington', 'DC', 'USA')
5> insert publishers values('3', 'Publisher C', 'Berkeley', 'CA', 'USA')
6> insert publishers values('4', 'Publisher D', 'New York', 'NY', 'USA')
7> insert publishers values('5', 'Publisher E', 'Chicago', 'IL', 'USA')
8> insert publishers values('6', 'Publisher F', 'Dallas', 'TX', 'USA')
9> insert publishers values('7', 'Publisher G', 'Vancouver', 'BC', 'Canada')
10> insert publishers values('8', 'Publisher H', 'Paris', NULL, 'France')
11> GO
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
1> CREATE TABLE titles(
2> title_id varchar(20),
3> title varchar(80) NOT NULL,
4> type char(12) NOT NULL,
5> pub_id char(4) NULL,
6> price money NULL,
7> advance money NULL,
8> royalty int NULL,
9> ytd_sales int NULL,
10> notes varchar(200) NULL,
11> pubdate datetime NOT NULL
12> )
13> GO
1>
2> CREATE TABLE sales(
3> stor_id char(4) NOT NULL,
4> ord_num varchar(20) NOT NULL,
5> ord_date datetime NOT NULL,
6> qty smallint NOT NULL,
7> payterms varchar(12) NOT NULL,
8> title_id varchar(80)
9> )
10> GO
1> insert sales values('1', 'QA7442.3', '09/13/94', 75, 'ON Billing','1')
2> insert sales values('2', 'D4482', '09/14/94', 10, 'Net 60', '1')
3> insert sales values('3', 'N914008', '09/14/94', 20, 'Net 30', '2')
4> insert sales values('4', 'N914014', '09/14/94', 25, 'Net 30', '3')
5> insert sales values('5', '423LL922', '09/14/94', 15, 'ON Billing','3')
6> insert sales values('6', '423LL930', '09/14/94', 10, 'ON Billing','2')
7> GO
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
1>
2> DELETE sales
3> FROM sales
4> JOIN titles t ON sales.title_id = t.title_id
5> JOIN publishers p ON t.pub_id = p.pub_id
6> WHERE p.pub_name = 'Publisher A'
7> GO
(0 rows affected)
1>
2> drop table sales;
3> drop table publishers;
4> drop table titles;
5> GO