PL/SQL Chapter III basic query statements

Source: Internet
Author: User

1 --Query All Columns select * from Tab_name|view_name;2 SELECT *  fromEMP;3 SELECT *  from(SELECT *  fromEMP);4 --Querying specific Columns5 SELECT *  fromEmpWHEREEmp.ename='SMITH';6 --Note PL/SQL developer does not support session control statements7 --Display date columns in a special format: data type is date or timestamp, default display format: DD-MON-RR8 ALTERSESSIONSETNls_date_language='Simplified Chinese';9 ALTERSESSIONSETNls_date_language='AMERICAN';Ten ALTERSESSIONSETNls_date_format='YYYY "Year" MM "month" DD "Day"'; One SELECT *  fromEMP; A SELECTEname,hiredate fromEMP; - --Customizing date display formats using the TO_CHAR function - SELECTEname,to_char (HireDate,'yyyy "Year"-mm_dd') fromEMP; the  - --Cancel duplicate columns, use keyword DISTINCT, use grouping methods - SELECTDeptno,job fromEMP; - SELECT DISTINCTDeptno,job fromEMP; + SELECTDeptno,job fromEmpGROUP  byDeptno,job; - --to display duplicate row data + SELECTDeptno,job fromEmpGROUP  byDeptno,job having COUNT(*)>1; A  at --using an arithmetic expression, the alias cannot use quotation marks SELECT ename,sal,sal*12 ' yearly ' from EMP; either use double quotation marks, or no, single quotation mark is not used. - SELECTEname,sal,sal* AAnnual salary fromEMP; - SELECTEname,sal,sal* A  as"Nianxin" fromEMP; - --using aliases - --processing Null:null represents an unknown value, not a space, or 0, note: When an expression contains null, the result is also null - --use NVL or NVL2 to handle null NVL equivalent to the ISNULL function in SQL Server in SELECTEname,sal,comm,sal+Comm fromEMP; - SELECTEname,sal,comm,sal+NVL (Comm,0) fromEMP; to SELECTENAME,SAL,COMM,NVL2 (Comm,comm+Sal,sal) fromEmp--NVL2 equivalent to three-dimensional expression +  - --connection string, using | | Operator or concat function the SELECTCONCAT (CONCAT (ename," "S Salary is'), Sal) fromEMP; *  $ --View TablePanax Notoginseng Selecttable_name fromAll_tables; - Selecttable_name fromUser_tables;

PL/SQL Chapter III basic query statements

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.