SQL syntax writing is very long, and SQLPLUS is not automatically completed. If you forget the format, you can get help through the document.
SQL syntax description in the official document:
1. keywords and Parameters
Square is the key word. elliptic is the parameter.
2. Optional parameters and keywords
The red color is optional and there are multiple paths, that is, the schema and vertex are optional, and the FORCE and VALIDATE are optional or links.
3. Loop syntax
Multiple Expressions can be separated by commas.
4. Cross-line syntax
The syntax is written in order. If an arrow is used to describe a line that is not described enough, another line is started.
5. When a statement contains clause, there is a separate clause syntax below.
The entire process of learning SQL is to use the SCOTT user's table to learn. scott is the locking and unlocking method by default.
SQL> conn/as sysdba
SQL> alter user scott account unlock identified by tiger;
Use sys to unlock scott and set scott's password to tiger
SQL> conn scott/tiger
In the future, scott's table is often modified. If you want to restore the scott environment, you can use the built-in script by default.
SQL> show user
USER is "SYS"
SQL> @? /Rdbms/admin/utlsampl. SQL
For windows @? /Rdbms/admin/scott. SQL
The example template is selected by the hr user when creating the database.
You can also create a script using the script. See the following summary.
@ Is to load the SQL statement in the OS to save the file
? Is an alternative to $ Oracle_HOME.
After the script is executed, it will automatically exit and log on again, and then unlock scott.
Simple select syntax structure (the reason is simple because the actual select syntax is very complex)
This is just a small part of the most commonly used syntax structure .)
SELECT {* | DISTINCT column | expression [[alias],...]}
FROM table [[alias],...]
WHERE expression
Order by {column | number} [DESC | ASC];
The above syntax is case-insensitive only for ease of Description
In actual writing, only strings are case-sensitive and must be included in a single reference.
In the description, uppercase is the keyword.
The lower case in the description is the table or the column alias expression selected
A complete SQL command is called a statement. Each keyword and the following option are called clause)
Select specifies the column to be queried
From specifies the table to be queried
Where filter conditions
Order by Column
DESC | ASC sorting method