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.
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.....);
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';
The results are as follows:
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');
The results are as follows:
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!