Test forms using the Oracle database:
--single-Table query data Syntax Select (query) * All/query fields, multiple fields, separating from table name--find information for all employeesSelect * fromscott.emp;Select * fromDept;--query all employee numbers, names and positions specify field names to find dataSelectEmpno,ename,job fromEMP;--Check the number, name and annual salary of all employeesSelect * fromEMP;SelectEmpno,ename,sal* A fromEMP;--using an operator with a query does not modify the original data--It's just an operation at the time of the query, showing a new data table .SelectEmpno,ename,sal* A fromEMP;--calculate the? Provides a virtual table, dual--dual is a virtual table that is designed for testing use--You can alias a fieldSelect 1+1 asResult1 fromdual;SelectSysdate asDATES fromdual;--alias Sal*12 changed to income as can be omitted--' single quotation mark for string ' "is used when aliases are used, if aliases contain special characters use" "to wrap upSelectEmpno,ename,sal* AAnnual salary fromEMP;--Query the names, positions, and salaries of all users and display them in the following manner--Name: xxx, job: xxx, Salary: XXX--string concatenation using | | Connection not +Select 'Name:'||Ename||', Position:'||Job||', Salary:'||Sal Info fromEMP;--want to show all the positions, can not duplicate the elimination of duplicates--to re-use distinctSelect distinctJob,ename fromEMP;--Sort Ascending and descending (ASC desc)--sort needs to specify sort fields by default ascending ASC--numeric date string types can be sortedSelect * fromEmpOrder byJobASC;--In descending order of salary, if the salary is the same, then the old employee is discharged to the back (date descending)--Sort by multiple fields, order by as long as write once, subsequent sort fields are used, separatedSelectEmpno,ename,hiredate,sal fromEmpOrder bySaldesc, HireDatedesc; --Check all employee numbers, names, annual salary, and sort by yearly salary--sorting can be used with aliasesSelectEmpno,ename,sal* AIncome fromEmpOrder byIncomedesc;
Oracle Single-Table query statements