DDL operations on Oracle databases

Source: Internet
Author: User


Create and manage Data Definition Language (DDL) statements are used to define the database structure or schema. some examples: · CREATE-to create objects in the database · ALTER-alters the structure of the database · DROP-delete objects from the database · TRUNCATE-remove all records from a table, including all spaces allocated for the records are remove D. COMMENT-add comments to the data dictionary · RENAME-rename an object www.2cto.com the data type keyword in Oracle remarks string Varchar2 (n) the string length is n integer Number (n) N is an integer decimal Number (n, m) M decimal n-m integer Date large text CloB massive text (4G) Large Object BloB storage binary data (1) create table Name (www.2cto.com column name 1 data type, column name 2 data type, column name 3 data type ,....) (2) alter table name alter table-alter table attribute ALTER table TABLE [*] ADD [COLUMN] column type [FIRST | After column] alter table table [*] MODIFY [COLUMN] column typeALTER TABLE table [*] DROP [COLUMN] columnALTER TABLE table [*] ALTER [COLUMN] column {set default value | drop default} alter table table [*] RENAME [COLUMN] column TO newcolumnALTER TABLE tableRENAME TO newtable www.2cto.com (3) drop drop table table_name purge // The deleted data will not be permanently deleted in the recycle bin, and the data deleted in the drop table table_name is E will exist in the recycle bin. There will be traces in the original Table. Oracle provides the FLUSHBACK technology to restore accidentally deleted data. The collective syntax is as follows: FlushBack Table table_name to before drop to view the recycle bin: show Recyclebin; clear the recycle bin: Purge Recyclebin directly deletes the data in the recycle bin: Purge table table_name (4) TRUNCATE; the data deleted from the truncated table will not be restored, which is equivalent to giving up the resources occupied by the table in the memory. Unlike the Delete operation, the deleted data can be rolled back through transactions) the specific syntax for table truncation is as follows: www.2cto.com Truncate table table_name; (1) Commit transaction concept of a COMMENT transaction: a transaction is a program execution unit consisting of a series of operation sequences, these operations are either done or not done, yes An inseparable work unit. (A set of operations) a transaction starts with Begin transaction and ends with Commit work or Rollback work. Commit work indicates that the transaction is committed and ends normally. Rollback work indicates that the transaction ends abnormally, undoing the operation that the transaction has done, and rolls back to the State at the beginning of the transaction. (2) RENAME Rename old_table_name to new_table_name;
 

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.