Table Operations (Oracle and DB2)

Source: Internet
Author: User

ASC and DESCIndicate ascending and descending, respectivelySELECT * FROM tablename ORDER BY id DESC: According to the ID field in descending order, from big to smallSELECT * FROM tablename ORDER by ID ASC: According to the ID field in ascending order, from small to largeClone tableThe methods for cloning tables in the DB2 database are as followsClone table:CREATE table clone table name like the table to be cloned;Inserting dataINSERT INTO Clone table select * from the table to be cloned;Oracle Database Cloning table:To clone the entire table:Create clone table name as SELECT * from the table to be cloned;---This includes all the data that was cloned.Clone only tables, do not clone data:Create clone table name as SELECT * FROM table to be cloned where 1=2;--is where it restricts the way you don't need data.If you need to add data later, you can use the following statement:INSERT INTO Clone table select * FROM table to be cloned; values are not allowed here---SQL query statement de-weight methodDB2 method of weight-down:CREATE TABLE clones a table (do re-use) like the original table;INSERT into clone table SELECT DISTINCT * from original table;SELECT * from clone table;Delete from the original table;INSERT into original table SELECT DISTINCT * from clone table;----------------------------DB2 de-weight method ----- Method One: ----using a copy table method can be achieved to go to the heavy mode, the main use of the SELECT statement has a method is distinct ----specifically implemented as follows: create Table clone tables like original table; ---------------insert a single data  INSERT into clone table SELECT DISTINCT * from the original table; ---------delete meta data delete from the original table; -------Insert new data insert into original table select * from clone table; ---------------------complete-------------      

Operations for tables (Oracle and DB2)

Related Article

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.