Basic Oracle Tutorial: simple SQL

Source: Internet
Author: User

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

  • 1
  • 2
  • 3
  • 4
  • Next Page

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.