described below:
§3.6.1 index based on functionA function based index is an index that stores a predefined function or expression value. These expressions can be arithmetic operational expressions, SQL or Pl/sql functions, C invocations, and so on. It is noteworthy that the general user must have the global QUERY rewrite and create any index permissions to create a function index. Otherwise, you cannot create a function index, see the following example:
Example 1: The index of the uppercase
function or expression value. These expressions can be an arithmetic expression, an SQL or a/PL function, a C call, and so on. It is worth noting that the general user to create the function index, must have the global QUERY rewrite and create any index permission. Otherwise, you cannot create a function index, see the following example:Example 1: Index of the uppercase conversion function for the ename column of the EMP table idx:CREATE INDEX idx on EMP (UPPER (ename));This allows you to use t
First, simple query statements1. View table structureSQL>DESC EMP;2. Querying all ColumnsSql>select * from EMP;3. Querying a specified columnSql>select empmo, ename, Mgr from EMP;Sql>select DISTINCT Mgr from EMP; Show only items with different results4. Querying a specified rowSql>select * from emp WHERE job= ' clerk ';5. Using an arithmetic expressionSql>select ename, SAL*13+NVL (comm,0) from EMP;NVL (comm
--(1) Query all employee information in department 20th.SELECT * from emp e where e.deptno=20;--(2) query bonus (COMM) employee information that is higher than the salary (SAL).SELECT * FROM EMP where comm>sal;--(3) To inquire about 20% of the employee information of the bonus above the salary.SELECT * FROM EMP where comm>sal*0.2;--(4) To inquire the information
The SELECT statement in SQLSpool d:\ basic query. txt--spool recorded on the screen as a text file--Clear screenHost Clear (Linux)Host CLS (window)--Current userShow user--The table under the current userSELECT * from tab; (tab data dictionary, tables and views)--Structure of the employee tableDESC EMPEmpno Employee number ENAME employee Name Job Mgr BossHireDate Entry date sal monthly Comm Bonus DEPTNO Department number--Query all employee informatio
Tags: need not output LIS Order multiple paging query arithmetic arcFirst, simple query statements 1. View table structure SQL>DESC EMP; 2. Querying all Columns Sql>select * from EMP; 3. Querying a specified column Sql>select empmo, ename, Mgr from EMP; Sql>select DISTINCT Mgr from EMP; Show only items with different results 4. Querying a specified row Sql>select * from emp WHERE job= ' clerk '; 5. Using an arithmetic expression Sql>select ename, SAL*13+NVL (
# Go to repeating fields#select distinct name,address from student# column Operations#select name, age+1 as age from student# NULL operation#select ifnull (address,0) + 1 as address from student# string Addition#select concat (address, ' str ') as address from studentSELECT * FROM dept;SELECT * from EMP;SELECT * from Stu;SELECT * from emp where job = ' manager ';SELECT * from emp where job! = ' manager ';SELECT * from emp where job Select Ename,job from emp where Sal > 20000;SELECT * from emp wh
displayed in case-sensitive format after double quotation marks are added.
Null Value
Summary: NULL values are invalid, unspecified, unknown, or unpredictable values. NULL values are not equal to 0 or spaces.
Example: select empno, ename, sal, comm from emp; -- after execution, the comm attribute of some records is displayed blank, that is, the null value.
Insert into student (age) values (24); -- when ins
For more information about SQL Server basic knowledge data retrieval and query of sorting statements, see.
For more information about SQL Server basic knowledge data retrieval and query of sorting statements, see.
The Code is as follows:
-- Execution sequence From Where Select
Select * from
(Select sal as salary, comm as commission from emp) x where salary -- Get Name Work as a Job
Select ename + 'work as a' + job as msg from emp where deptno = 10
--
used in the alias or the output is case-insensitive.Format: SELECT
|
[[AS]
],... FROM
;
Example: select empno, ename "Ename", sal * 12 "annual salary" from emp;
Select empno as employee ID, ename employee name, sal * 12 "annual salary" from emp;
Note: as can be skipped. Aliases can be enclosed in double quotation marks. If the alias does not contain special characters, double quotation marks can be omitted.
If the alias contains spaces, such a
) from emp;5. SQL and SQL * PlusYou can use SQL * Plus:Describes the table structure, edits SQL statements, and executes SQL statements. Save the SQL statement in the file and save the SQL statement execution result in the file. Execute the statement in the saved file. Load the text file into the SQL * Plus editing window.6 Other comparison operationsUse the LIKE operation to select a similar value;The selection condition can contain characters or numbers: % Represents zero or multiple character
of rows selected is displayed.14. set feedback on; displays the number of rows selected during execution.15. set heading off; cancel the header information of the field16. set heading on; displays the header information of the field.17. set trimout on;18. set trimout off;Ii. query table:1. select * from tabs; query system table2. select table_name from user_tables; Name of the table under the current user3. desc table name query table structure4. set linesize 120 to set the Row Height5. col nam
characters (any character); _ represents one character; '%' and '-' can be used at the same time; you can use the ESCAPE identifiers to select the '%' and '_' symbols. To avoid special symbols, use ESCAPE characters. For example, convert [%] to [\ %], [_] to [\ _], and then add [ESCAPE '\']. Use IS (NOT) NULL determines the NULL value.
Example:
Select * from emp where sal between 1000 and 2000; empno ename job mgr hiredate sal comm deptno ----------
special characters are used in the alias or the output is case-insensitive.
Format: SELECT
|
[[AS]
],... FROM
;
Example: select empno, ename "Ename", sal * 12 "annual salary" from emp;
Select empno as employee ID, ename employee name, sal * 12 "annual salary" from emp;
Note: as can be skipped. Aliases can be enclosed in double quotation marks. If the alias does not contain special characters, double quotation marks can be omitted.
If the alias conta
(commonly used) is returned)For example, if an employee has no commission, 0 is displayed; otherwise, the Commission is displayed.Select comm, nvl (comm, 0) from emp;Nullif (ex1, ex2 ):Returns NULL if the value is equal. Otherwise, the first value is returned.For example, if the salary is equal to the Commission, it is blank; otherwise, the salary is displayed.Select nullif (sal,
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.