Chapter One: The SELECT statement of the ORACLE_SQL statement

Source: Internet
Author: User

What tables does the Scott user own?

Sql>select * from Tab;


Querying all rows in a table for all columns

Sql>select * FROM Dept;

Sql>select * from EMP;


Save the command for the buffer as a script:

Sql>save 1.sql


To view the contents of a script file:

Sql>get 1.sql


To run the script file:

Sql>@1.sql


Querying columns of interest in a table

Select Ename,sal from EMP;


Using Arithmetic in queries

Select ename,sal*12 from EMP;


Select Ename,comm,sal+comm from EMP;


Null value (NULL): Undefined value, indeterminate value, not 0 and not a space!

Null values cannot be directly involved in arithmetic!


Naming a column alias in a query

Select Ename,sal*12 as annual_salary from EMP;

--as is an optional keyword that can be omitted

Select Ename,sal*12 annual_salary from EMP;


Using special characters in aliases, aliases are double-cited

Select ename,sal*12 "Annual salary" from EMP;


Join operator: Combine multiple columns into one column of output

Select Ename,job from EMP;

Select Ename| | ' is a ' | | Job from EMP;


Compress duplicate values

Select Deptno from EMP;

SELECT DISTINCT deptno from EMP;


Describe table structure

DESC EMP

Exercise 1

The 1th chapter is the basic SELECT statement:

1. Make a query to display all the data for the Dept table

2. Make a query to display the Ename,job,sal in the EMP table, where the SAL column does salary display in the result set

3. Make a query to display the EMP table in Deptno,ename, annual salary, and name the annual wage alias annual salary

4. Get the structure of the EMP table

5. Make a query showing the EMP table employee number, employee name, job, hire date, and save query as script, script name P1q7.sql

6. Running P1q7.sql

7. Create a query that displays the department number in the employee table, and the duplicate department number is displayed only once

8. The employee name and work in the result set are separated by a "space comma space" and the column header is displayed as employee and Title


Chapter One: The SELECT statement of the ORACLE_SQL statement

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.