Home > Database > Oracle > body text

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

WBOY
Release: 2022-02-10 18:26:08
forward
3671 people have browsed it

This article brings you relevant knowledge about Oracleadding 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(值列表);
Copy after login

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;
Copy after login

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','北京海淀');
Copy after login

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','北京海淀');--类型不一致错误
Copy after login

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');--没有足够的值
Copy after login
insert into studentInfo(studentId,stuName,sex,age,phone ,email,address)
values(2,'张帅','男',21,'32165498745','zhang@126.com','北京海淀','描述'); --值过多
Copy after login

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');
Copy after login

The value is written as null

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

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','北京西城');
Copy after login

Write default

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

Omit column name list

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

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template