Get the App
SLTechnology News&Howtos  ›  Database  › 

How to add, modify and delete rows in oracle database

Shulou Source: shulou.com Published: 2022-05-31 21:03:24 10月17日 Update

Oracle database how to add, modify and delete rows, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Add rows to the table:

The INSERT statement has the courage to add new rows to the table, and the following information can be specified in the INSERT statement:

1. Which table do you insert rows into?

two。 Specify values for those columns

3. Values stored in these columns

When inserting a row, at least specify the values of the primary key and all other columns defined as NOT NULL, except that the values of all columns are optional, if you do not want to specify values for these columns, you can not specify them, and the values of these columns are automatically set to null.

Modify an existing row in the table:

The modification of the tables in the database can be achieved with the UPDATE statement, and when using the update statement, you need to make the following:

1. The table containing the rows to be modified

two。 WHERE clause that indicates the row to be modified

3. The hunting list and its new values, which are specified using the SET clause

A UPDATE statement can modify one or more rows, and if multiple rows are specified, the same modification will be made to those rows. The following UPDATE statement changes the last_name column of the row in the customers table with a value of 2 to Orange:

SQL > UPDATE customers

2 SET last_name = 'Orange'

3 WHERE customer_id = 2

1 row updated.

SQL*plus confirms that a row of records has been updated.

Delete rows from the table

The DELETE statement is used to delete rows from a table, similar to the UPDATE statement, usually using a WHERE clause to restrict the rows you want to delete. If you do not use the WHERE clause, all rows in the table will be deleted. The following example uses a DELETE statement to delete a row with a customer_id of 2 from the customers table:

SQL > DELETE customers

2 WHERE customer_id = 2

1 row updated.

SQL*plus confirms that a row has been deleted. To undo the changes you just made to the database, you can use the ROLLBACK command:

SQL > ROLLBACK

Rollback complete.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Statement clause data database one line content multiple lines help clear same table example information command for this article novice more knowledge industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information OPPO Reno vpn Shulou Tech Info Shulou Technology