DML statement and table connection

Source: Internet
Author: User
Tags dname

DML statement and table join Cartesian Product: (1992) SQL> select ename, dname from emp, dept; (1999) SQL> select ename, dname from emp cross join dept; query the same number in the middle of emp and dept: SQL> select ename, dname from emp, dept where emp. deptno = dept. deptno; SQL> select ename, dname from emp join dept on (emp. deptno = dept. deptno); SQL> select ename, DNA m from emp join dept using (deptno); query the salary level; SQL> select ename, grade from emp e join salgrade s on (e. sal between s. losal and s. hisal); SQL> select ename, dname, grade from emp ejoin dept d on (e. deptno = d. deptno) join salgrade s on (e. sal between s. losal and s. hisal) where ename not like '_ A %'; query the manager of each employee: SQL> select e1.ename, e2.ename from emp e1 join emp e2 on (e1, mgr = e2.mgr ); outer join: left join: SQL e1.ename, e2.ename from emp e1 left join emp e2 on (e1.mgr = e2.mgr); right join: SQL> select ename, dname from emp e right outer join dept d on (e. deptno = d. deptno); full join: SQL> select ename, dname from emp e full join dept d on (e. deptno = d. deptno); Simple connection: SQL> select e1.ename, e2.ename from emp e1 left join emp e2 on (e1.mgr = e2.empno); DML statement select to query existing data: insert data into the data table: update modify the statement in the existing database: delete the data in the database; only the super administrator can add the user: conn sys/*** as sysdba; (delete a user) drop user xiaoming cascade; 1. backup scott (back up data related to scott users) exp import scott data to a new user; 2 create a new user: create user xiaoming identified by xiaoming default tablespace usersquota 10 M on users; grant permissions to users: grant create session, create table, create view to xiaoming; 3 import the data rollback (rollback to the previous operation); Back up the emp table: create table emp2 as select * from emp; insert data in dept2: insert into dept2 values (50, 'game', 'bj '); insert the data of the Department field: insert into dept2 (deptno, dname) values (60, 'game2 '); insert a table from the subquery, but the two tables have the same structure: insert into dept2 select * from dept; update application: update emp2 set sal = sal * 2, ename = ename | '-' where deptno = 10; select ename, sal from emp2 where deptno = 10; delete applications: delete from emp2; delete from dept2 where deptno; rollback

Related Article

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.