Home>Article>Database> Summarize and organize Oracle’s add statements (summary sharing)

Summarize and organize Oracle’s add statements (summary sharing)

WBOY
WBOY forward
2022-02-10 18:25:45 3601browse

This article brings you relevant knowledge aboutOracleadding statements, including the syntax and default values of adding statements and other related issues. I hope it will be helpful to everyone.

Summarize and organize Oracle’s add statements (summary sharing)

Add a statement

Syntax of adding a statement:

insert into 表名(列名列表) values(值列表);

Note:

1) Add a Record

2) The order, type and number of the value list corresponding to the column name list

3) In addition to numerical types, other types of values in the value list are enclosed in single quotes.

4) Assign a null value to a nullable column 4.1) Do not write this column in the column list 4.2) Write the value as null

5) Directly use the default value for a column with a default value 5.1 ) Do not write this column in the column list 5.2) Write the value as default

6) The column name list can be omitted. Note that the order of the value list must be consistent with the order of the columns when defining the table (not recommended)

Student table

select * from studentInfo;

Add a piece of data to the student table

insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values(1,'张三','男',21,'32165498747','zhang@126.com','北京海淀');

The value is consistent with the column order and type

insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values('张三',1,'男',21,'32165498747','zhang@126.com','北京海淀');--类型不一致错误

The number of values is consistent with the number of columns Consistent

insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values(2,'张帅','女',21,'32165498745','zhang@126.com');--没有足够的值
insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values(2,'张帅','男',21,'32165498745','zhang@126.com','北京海淀','描述'); --值过多

Assign the value to the nullable column as null

The address column is empty (omit this column name)

insert into studentInfo(studentId,stuName,sex,age,phone ,email) values(2,'张帅','男',21,'32165498745','zhang@126.com');

The value is written as null

insert into studentInfo(studentId,stuName,sex,age,phone ,email,address) values(9,'大山','男',22,null,'oracle@126.com',null);

To Columns with default values use default values

Omit columns with default values

insert into studentinfo(studentId,stuName,age,phone,address) values(10,'李林',21,'14785236956','北京西城');

Write default

insert into studentInfo(studentid,stuname,sex,age, phone,email,address) values(11,'蔡徐坤',default,20,'45632178954',default,null);

Omit column name list

insert into studentinfo values(12,'邓伦',default,22,null,null,default);

Submit Data

commit;

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of Summarize and organize Oracle’s add statements (summary sharing). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete