27>
28>
29> CREATE TABLE department(dept_no CHAR(4) NOT NULL,
30> dept_name CHAR(25) NOT NULL,
31> location CHAR(30) NULL)
32>
33> insert into department values ('d1', 'developer', 'Dallas')
34> insert into department values ('d2', 'tester', 'Seattle')
35> insert into department values ('d3', 'marketing', 'Dallas')
36>
37> select * from department
38> GO
(1 rows affected)
(1 rows affected)
(1 rows affected)
dept_no dept_name location
------- ------------------------- ------------------------------
d1 developer Dallas
d2 tester Seattle
d3 marketing Dallas
(3 rows affected)
1>
2> -- Inserts one or more rows selected with a subquery.
3>
4> CREATE TABLE dallas_dept
5> (dept_no CHAR(4) NOT NULL,
6> dept_name CHAR(20) NOT NULL)
7>
8> INSERT INTO dallas_dept (dept_no, dept_name)
9> SELECT dept_no, dept_name FROM department WHERE location = 'Dallas'
10>
11> select * from dallas_dept
12> Go
(2 rows affected)
dept_no dept_name
------- --------------------
d1 developer
d3 marketing
(2 rows affected)
1>
2> drop table department
3> drop table dallas_dept
4> GO
1>
2>
|