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