Data deletion and modification

Source: Internet
Author: User

1.INSERT statements
Adding records to a data table
The syntax is as follows:
INSERT into table_name[(Column[,column ...]) VALUES (Value[,value ...]);
After performing the DML operation, the commit statement needs to be executed before the operation is truly confirmed.
If the inserted column has a date field, you need to consider the format of the date
The default date format, converted to date type data with the To_date function
--Inserting records using the default date format
INSERT into Myemp (Id,name,job,birth) VALUES (1002, ' Martha ', ' ANALYST ', ' 01-sep-03 ');
--Insert a record using a custom date format
INSERT into Myemp (Id,name,job,birth) VALUES (1003, ' Donna ', ' MANAGER ', to_date (' 2009-09-01 ', ' yyyy-mm-dd '));
2.UPDATE statements
Update records in a table
The syntax is as follows:
UPDATE table_name SET column = value [, Column=value] ... [WHERE condition];
If there is no WHERE clause, the data for the entire table will be updated, so be careful.
3.DELETE statements
Delete a record in a table
The syntax is as follows:
DELETE [from] table_name [WHERE condition];
If there is no WHERE clause, the data for the entire table will be deleted!
The TRUNCATE statement in the DDL statement also has the effect of deleting the table data.
The difference between the and DELETE statements:
Delete can be conditionally deleted, truncate all table data
Delete is a DML statement that can be rolled back, truncate is a DDL statement that immediately takes effect and cannot be rolled back
If you delete all table records, and the amount of data is large, the DELETE statement is less efficient than the TRUNCATE statement.
--Delete all records
DELETE from Myemp;
-OR
TRUNCATE TABLE myemp;

Data deletion and modification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.