Tags: ar using for SP strong data on Art BSWhen Oracle implements paging, a rownum function needs to be introduced, and rownum can record an ID-like field.The following is a collection of several commonly used SQL paging algorithm, the database with the EMP in Oracle as an example. The query results are as follows:Sql> select * from EMP;EMPNO ename JOB MGR hiredate SAL COMM DEPTNO----- ---------- --------- ----- ----------- --------- --------- ------7369 SMITH Clerk 7902 1980/12/17 800.00 207499
Syntax: coalesce (T V1, t V2 ,...)The first non-null value in the returned parameter. If all values are null, null is returned.
Take the EMP table as an example:
desc emp;empno int None ename string None job string None mgr int None hiredate string None
3000MILLER salary is 1300 PL/SQL procedure successfully completed >--cursor Exercise: Giving employees a raise in wages President 1000 Manager 800 other 400sql>--first check the sql> select * from EMP before the rise; EMPNO ename JOB MGR hiredate SAL COMM DEPTNO---------------------------------------------- ------------------7369 SMITH Clerk 7902 1980/12/17 800.00 7499 ALLEN salesman 769 8 1981/2/20 1600.00 300.00 7521 WARD salesman 7698
Tags: mysql5.6 data sheetLet's take a look at the data structures of several tables of Scott users in Oracle:==============================================================The following operations are performed in the Oracle database (if required)==============================================================To create a table:CREATE TABLE Dept (deptno INT PRIMARY key,dname varchar, loc VARCHAR (13)); CREATE TABLE EMP (EMPNO int (4) PRIMARY KEY, ename varchar (ten), JOB VARCHAR (9), MGR INT (4), Hi
Label:for the analysis function, you should pay attention to:1The parse function is performed after the end of the SQL query (the execution of the order by in the SQL statement is special), that is, the order by in the SQL statement also affects the result of the analysis function execution, see: SQL> SelectDeptno,2empno,3ename,4Sal,5HireDate,6Last_value (SAL) Over(Partition bydeptno) Last_value7 fromEMP8 whereDeptno= -;D eptno EMPNO ename SAL hiredate last_value------ ----- ---------- --
set operators--Generates an EMP table with the same structure for the set operation generation environment, named EMP2Idle> select * from EMP; EMPNO ename JOB MGR hiredate SAL commdeptno----------------------------------------------------- --------------------------7369 SMITH clerk 7902 1980-12-17 7499 ALLEN salesman 7698 1981-02-20 1600300 7521 WARD salesman 7698 1981-02-22 1250500 7566 JONES
not be created) if you already exist directly into the database to manipulate the databaseIn SQLite command:Start with., Case sensitive (database object names are case insensitive). exit. Help view assistance for commands. Database displays information about the databases, and contains the location of the current databaseThe. Tables or. Table display table name does not appear without a tableThe. Schema command can view SQL commands when creating data objects;. Schema databaseobjectname the com
| Salesman|7698|20-02-1981|1600|300|30Assuming that the field value is NULL, the default is to display an empty stringsqlite>. Mode columnSqlite> select * from EMP;7369 SMITH Clerk 7902 17-12-1980 800 207499 ALLEN salesman 7698 20-02-1981 1600 300 307521 WARD salesman 7698 22-02-1981 1250 500 30sqlite>. Mode InsertSqlite> select * FROM dept;INSERT into Table VALU
|7698|20-02-1981|1600|300|30Assuming that the field value is NULL, the default is to display an empty stringsqlite>. Mode columnSqlite> select * from EMP;7369 SMITH Clerk 7902 17-12-1980 800 207499 ALLEN salesman 7698 20-02-1981 1600 300 307521 WARD salesman 7698 22-02-1981 1250 500 30sqlite>. Mode InsertSqlite> select * FROM dept;INSERT into Table VALUES (' ACCO
employee information whose name is king, the lower function and upper () function are introduced to ensure the validity of the query because we are not sure about the case format of the database name.
SQL> select * from emp where lower(ename) = 'king' ; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO----- ---------- --------- ----- ----------- --------- --------- ------ 7839 KING PRESIDENT 1981/11/17 5000.00
subquery:When the subquery returns the result of a single row egg data record, the subquery is generally in the WHERE clause of the main query statement, typically including the comparison operator (> 5.2.1 Single-row subquery:
Example (all employee information with a salary higher than Smith):
Mysql> SELECT * from T_employee where sal > (select Sal from T_employee where Ename= ' Smith '); +-------+---------+-----------+------+------------+---------+---------+--------+
| Empno | ename | J
not be created) if you already exist directly into the database to manipulate the databaseIn SQLite command:Start with., Case sensitive (database object names are case insensitive). exit. Help view assistance for commands. Database displays information about the databases, and contains the location of the current databaseThe. Tables or. Table display table name does not appear without a tableThe. Schema command can view SQL commands when creating data objects;. Schema databaseobjectname the com
Practice One:"Construct implementation environment----execute under any user"DROP TABLE DEPT;CREATE TABLE DEPT (DEPTNO number (2) CONSTRAINT pk_dept PRIMARY KEY,
Dname VARCHAR2, LOC VARCHAR2 (13)); DROP TABLE EMP;CREATE TABLE EMP (EMPNO number (4) CONSTRAINT pk_emp PRIMARY key,ename VARCHAR2 (Ten), job VARCHAR2 (9), mgr Number (4), hiredate date,sal number (7,2), comm number (7,2), deptno number (2) CONSTRAINT Fk_ DEPTNO REFERENCES dept); insert into DEPT values (' ACCOUNTING ', ' NEW YORK ');
example, to query the employee information whose name is king, the lower function and upper () function are introduced to ensure the validity of the query because we are not sure about the case format of the database name.
SQL> select * from emp where lower(ename) = 'king' ; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO----- ---------- --------- ----- ----------- --------- --------- ------ 7839 KING PRESIDENT 1981
Oracle Constraints
* If a constraint only applies to individual fields, you can define the constraint at the field level or at the table level. However, if a constraint acts on multiple fields,Constraints must be defined at the table level* When defining a constraint, you can use the constraint keyword to name the constraint. If not specified, oracle automatically creates a default name for the constraint.
Define the primary key constraint (single field)Create table employees (empno number (5) p
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.