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;