The order of the columns in the insert statement
4>
5>
6> CREATE TABLE employee (emp_no INTEGER NOT NULL,
7> emp_fname CHAR(20) NOT NULL,
8> emp_lname CHAR(20) NOT NULL,
9> dept_no CHAR(4) NULL)
10>
11> insert into employee values(1, 'Matthew', 'Smith', 'd3')
12> insert into employee values(2, 'Ann', 'Jones', 'd3')
13> insert into employee values(3, 'John', 'Barrimore','d1')
14> insert into employee values(4, 'James', 'James', 'd2')
15> insert into employee values(5, 'Elsa', 'Bertoni', 'd2')
16> insert into employee values(6, 'Elke', 'Hansel', 'd2')
17> insert into employee values(7, 'Sybill', 'Moser', 'd1')
18>
19> select * from employee
20> GO
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
emp_no emp_fname emp_lname dept_no
----------- -------------------- -------------------- -------
1 Matthew Smith d3
2 Ann Jones d3
3 John Barrimore d1
4 James James d2
5 Elsa Bertoni d2
6 Elke Hansel d2
7 Sybill Moser d1
(7 rows affected)
1>
2>
3> -- The order of column names in the VALUE clause can be different from the order of those columns determined in the CREATE TABLE statement
4>
5> INSERT INTO employee (emp_lname, emp_fname, dept_no, emp_no)
6> VALUES ('Davis', 'Dave', 'd1', 15201)
7>
8> select * from employee
9> GO
(1 rows affected)
emp_no emp_fname emp_lname dept_no
----------- -------------------- -------------------- -------
1 Matthew Smith d3
2 Ann Jones d3
3 John Barrimore d1
4 James James d2
5 Elsa Bertoni d2
6 Elke Hansel d2
7 Sybill Moser d1
15201 Dave Davis d1
(8 rows affected)
1>
2> drop table employee
3> GO
1>
Related examples in the same category