Oracle Basic SQL SELECT statement

Source: Internet
Author: User

SELECT * |    {[ DISTINCT ] column | expression [alias], ...}

from table;


? Select identifies which columns are selected. From identifies the table from which to select.

The column is followed by a space, followed by the alias, or as Alias, to the next line of content, to be separated by commas,

The default alias is lowercase, and if you want it to be uppercase, use the alias

If the alias has multiple words, use a double-quote alias, such as "annual salary"

Select employee_id ID, first_name name from employees;
Results:

.....

193 Britney
194 Samuel
ID NAME
------- --------------------
195 Vance
196 Alana
197 Kevin
107 Rows Selected



Connector:

? concatenate columns and columns with characters.||' Represent.? ' can be used to ' synthesize ' columns.

Select Last_name| | "s eamil is ' | | email from employees;

similar to the System.out.println in Java (123+ "Hello" + 123);//123hello123

By default, the query returns all rows, including duplicate rows.


Delete duplicate rows using the keyword 'DISTINCT' in the SELECT clause.

Select distinct department_id from employees;
department_id
-------------
100
30
20
70
90
110
50
40
80
10
60
Rows selected



SQL Statement and sql*plus command

Structural Query Language

Sql

?A language?ANSI Standard?Keywords cannot be abbreviated?Use statements to control the definition information of tables in a database and the data in a table


Sql*plus

?An environment
?One of the features of Oracle?Keywords can be abbreviated Desc EMPLOYEES,DESC is the keyword of SQL Plus, the full name is describe;Ed is also the keyword for SQL Plus, and the full name is edit?Command cannot change the value of data in a database?Centralized operation
Summarize:
1. For date type data, do *,/operation is not legal


2. Null values for mathematical expressions that contain null values


3. Use double quotes for aliases!


4. The connection string in Oracle uses "| |" instead of "+" in Java


5. Dates and characters can only appear in single quotation marks. Output last_name ' s email is email


Select Last_Name | | ' s email is ' | | Email email
From Employees


6. Distinct keyword, the following syntax error


Select last_name, Distinct department_id
From Employees

Exercises:

Sql*plus command can control the database? No! Sql*plus is just a running environment that controls the SQL language of the database.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Oracle Basic SQL SELECT statement

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.