Home > Database > Oracle > body text

How to use insert in oracle

下次还敢
Release: 2024-05-02 23:54:37
Original
1065 people have browsed it

The INSERT statement in Oracle is used to insert new rows into the table. The syntax is: INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...), where table_name is the table Name, column1, column2, ... are column names, value1, value2, ... are values. Multiple rows can be inserted. NULL values ​​must be inserted. The values ​​must be compatible with the data type. Repeated primary key values ​​cannot be inserted, which will trigger The defined trigger, if no column name is specified, will be inserted in table column order.

How to use insert in oracle

INSERT statement in Oracle

In Oracle database, INSERT statement is used to insert new rows in the table .

Syntax

<code>INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);</code>
Copy after login

Parameters

  • table_name: The target table to insert rows into name.
  • column1, column2, ...: The column names of the table into which values ​​are to be inserted.
  • value1, value2, ...: The value in the column to be inserted.

Example

Insert the following rows into the employees table:

<code>INSERT INTO employees (employee_id, first_name, last_name)
VALUES (100, 'John', 'Smith');</code>
Copy after login

Insert multiple rows

To use the INSERT statement to insert multiple rows, you can use multiple VALUES clauses, as shown below:

<code>INSERT INTO employees (employee_id, first_name, last_name)
VALUES (100, 'John', 'Smith'),
       (101, 'Jane', 'Doe'),
       (102, 'Peter', 'Parker');</code>
Copy after login

Insert NULL values

To insert NULL values, you can use NULL keyword, as shown below:

<code>INSERT INTO employees (employee_id, first_name, last_name)
VALUES (100, 'John', NULL);</code>
Copy after login

Note

  • The value to be inserted must be compatible with the data type of the target column.
  • The INSERT statement does not allow inserting duplicate primary key values.
  • The INSERT statement will fire any trigger defined on the table.
  • If no column name is specified, the INSERT statement will insert values ​​in the table's column order.

The above is the detailed content of How to use insert in oracle. 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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template