Oracle Basic query Statements and examples

Source: Internet
Author: User
Tags logical operators

1. Query all Columns

SELECT * from table name;

2. Query table structure

DESC table name;

3. Query the specified column

Select Ename,sal,job from table name;

4. View all tables and fields in Oracle

Get table:

Select table_name from User_tables; The current user's table

Select table_name from All_tables; All users ' tables

Select table_name from Dba_tables; including system tables

Select table_name from dba_tables where owner= ' user name '

5. Where sentence

SELECT * from table name where field > value;

SELECT * from indicates where to_char (field, ' Yyyy-mm-dd ') > ' 1982-1-1 '; To_char conversion function

SELECT * from indicates where to_char (field, ' yyyy ') = ' 1980 ';

SELECT * from indicates where to_char (field, ' mm ') = ' 4 ';

Show wages at 2000 to 2500 wages

SELECT * from table name where field >=2000 and field <=2500;

SELECT * from indicates where field between and 2500;

6, Fuzzy query like

%: Represents any 0 to more characters; _: represents any single character

How to display the employee's name and salary for the first letter S

Select Eaname, sal from table name where Eaname like ' s% ';

How to display all employee names and wages for the third letter O

Select Eaname, sal from table name where Eaname like ' __o% ';

7. Where statement uses in

How to display an employee with a empno of 123,345,678

1. Select * from indicates where empno=123 or empno=345 or empno=678;

SELECT * from indicates where empno in (123,345,678);

2, is null empty value query

SELECT * from indicates that the where field name is null;

3. Oracle Logical operators

Check your salary above 500 or post for MSN employees, and also meet their initials University J

SELECT * from indicates where (sal>500 or job= ' MSN ') and (Enname like ' j% ');

Oracle Basic query Statements and examples

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.