Oracle basic SQL SELECT statement, oracleselect

Source: Internet
Author: User
Tags table definition

Oracle basic SQL SELECT statement, oracleselect

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

FROM table;


• SELECT identifies the columns to be selected. • FROM identifies FROM which table to select.

Add spaces after column and keep up with the alias (alias) or as alias. Separate the content in the next line with commas,

The default alias is lowercase. If you want to make it uppercase, use "alias"

If an alias has multiple words, use double quotation marks, for example, "annual salary"

select employee_id id, first_name name from employees;
Result:

.....

193 Britney
194 Samuel
Id NAME
---------------------------
195 Vance
196 Alana
197 Kevin
107 rows selected



Connector:

• Concatenates columns, columns, and characters. • It is represented by '|. • It can be used to 'composite 'columns.

Select last_name |'s eamil is '| email from employees;

Similar to System. out. println (123 + "hello" + 123) in Java; // 123hello123

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


Use the keyword 'distinct 'in the SELECT clause to delete duplicate rows.

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



SQL Statement and   SQL * Plus Command

Structural query language

SQL

• One language • ANSI standard • keyword cannot be abbreviated • use statements to control table definition information and data in a database


SQL * Plus

• An environment
• One of the features of Oracle • the keyword can be abbreviated as desc employees. desc is the keyword of SQL plus, and the full name is describe; ed is also the keyword of SQL plus, the full name is edit • the command cannot change the value of data in the database • Centralized Operation
Summary:
1. For date-type data, do *,/operation is invalid


2. The values of all mathematical expressions containing null values are null.


3. Double quotation marks for aliases!


4. Use "|" as the connection string in oracle, instead of "+" in java"


5. the date and character can only appear in single quotes. Output last_name's email is email


Select last_name |'s email is '| email
From employees


6. distinct keyword, the following syntax error


Select last_name, distinct department_id
From employees

Exercise:

Can the SQL * PLUS command control databases? No! SQL * PLUS is only a running environment, and the database is controlled by the SQL language.



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.