Simple oracle query, simple oracle

Source: Internet
Author: User

Simple oracle query, simple oracle

Data Query uses the SELECT command to extract information from the database table.

Syntax structure: simple query


SELECT * | column name | expression FROM table name WHERE condition order by column name


Syntax Parsing:
* Indicates all columns in the table.
You can select multiple columns in a table. The columns are separated by commas.
An expression can be an expression composed of column names, functions, constants, etc.
The WHERE clause is a query condition.
Order by must be sorted in the query results. The default value is ascending.

In Oracle, you can create a new table based on the table structure and data in the result set.
Syntax structure: Create a table based on the result set


Create table name as select statement

 

Code Demonstration: Create a table based on the result set


SQL> CREATE TABLE INFOS1 AS SELECT * FROM INFOS;

 

The new table created using the command above does not have any constraints and the queried data is inserted into the new table together.
If you only copy the table structure, you only need to make the query condition not true (for example, where 1 = 2). Then, no data is queried and a table structure is copied.
 
Code Demonstration: copy the table structure


SQL> CREATE TABLE INFOS2 AS SELECT * FROM INFOS WHERE 1 = 2;

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.