Home > Database > Oracle > What is the usage of oracle insert?

What is the usage of oracle insert?

青灯夜游
Release: 2022-04-18 18:14:36
Original
21041 people have browsed it

In Oracle, the insert statement is used to insert one or more rows of data into the data table. The syntax is "insert into table name (column name 1, column name 2, column name 3...) values" (Value 1, Value 2, Value 3...);"; The number of column names and the number of values ​​must be consistent, and the value type and column type must correspond one to one.

What is the usage of oracle insert?

The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.

In Oracle, the insert statement is used to insert one or more rows of data into a data table.

insert command structure:

insert into 表名(列名1,列名2,列名3.....)values(值1,值2,值3.....);
Copy after login

Syntax analysis:

1. The column name can be omitted. When the column name is not filled in, the default is table All columns in are arranged in the order in which the table was created.

2. The number of column names and the number of values ​​must be consistent, and the type of values ​​must correspond to the type of columns.

3. When certain constraints are set on certain fields in the table, the value must be inserted according to the constraints of the fields. For example: the student information table (STUINFO) is set with a primary key (primary key field is STUID), so this field must be unique and cannot be repeated with the original data. Fields such as age, stuname, and calassno are required fields, so they must have values.

Case 1: Insert a piece of data into the student information table (stuinfo):

insert into STUDENT.STUINFO (STUID, STUNAME, SEX, AGE, CLASSNO, STUADDRESS, GRADE, ENROLDATE, IDNUMBER)
values ('SC201801005', '龙七', '1', 26, 'C201801', '福建省厦门市XXX号', '2018', to_date('01-09-2018', 'dd-mm-yyyy'),
 '3503021992XXXXXXXX');
select * from student.stuinfo t where t.stuid='SC201801005';
Copy after login

The results are as follows:

What is the usage of oracle insert?

Case 2: Insert duplicate data into the student information table (stuinfo):

insert into STUDENT.STUINFO (STUID, STUNAME, SEX, AGE, CLASSNO, STUADDRESS, GRADE, ENROLDATE, IDNUMBER)
values ('SC201801005', '龙七', '1', 26, 'C201801', '福建省厦门市XXX号', '2018', to_date('01-09-2018', 'dd-mm-yyyy'),
 '3503021992XXXXXXXX');
Copy after login

The results are as follows:

What is the usage of oracle insert?

Recommended tutorial: " Oracle Tutorial

The above is the detailed content of What is the usage of oracle insert?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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