-
在SQL语言基础中插入新行
资源介绍
插入新行
*
SQL> INSERT INTO dept (deptno, dname, loc)
2 VALUES (50, 'DEVELOPMENT', 'DETROIT');
1 row created.
插入包含每一个列值的新行.
按缺省顺序列出表中所有的列值.
列出 INSERT 子句中所有的列.
日期值和字符值要用单引号括起来.
*
INSERT INTO dept (deptno, dname, loc)
VALUES (50, 'DEVELOPMENT', 'DETROIT');
Adding a New Row to a Table (continued)
Because you can insert a new row that contains values for each column, the column list is not required in the INSERT clause. However, if you do not use the column list, the values must be listed according to the default order of the columns in the table.
SQL> DESCRIBE dept
Name Null? Type
------------------------------- -------- ------------
DEPTNO NOT NULL NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
For clarity, use the column list in the INSERT clause.
Enclose character and date values within single quotation marks; do not enclose numeric values within single quotation marks.
Instructor Note
Number values should not be enclosed in single quotes, because implicit conversion may take place for numeric values assigned to NUMBER datatype columns if single quotes are included.
- 上一篇: 在子查询中使用ALL操作符-SQL语言基础
- 下一篇: INSERT语句-SQL语言基础