集合操作符UNION/UNION ALLINTERSECTMINUS Union All不排序,不去重,其余均升序且去重.create table e1 as select * from emp where deptno in (10,20);create table e2 as select * from emp where deptno in (20,30); select * from e1 union select * from e2 order by 8select * from e1…
集合操作符 Union / UnionAll / Intersect / Minus -- 生成测试数据 create table dept_01 as select * from dept where rownum < 6; create table dept_02 as select * from dept where rownum < 4; insert into dept_02 values (98, '小吃部', '斗门'); insert into dept_02 values (…
SQL Server中的集合运算包括UNION(合并),EXCEPT(差集)和INTERSECT(相交)三种. 集合运算的基本使用 1.UNION(合并两个查询结果集,隐式DINSTINCT,删除重复行) --合并两个提取表/派生表(derived table), 返回结果为:[a,b,c,d,e] SELECT FC FROM (VALUES('a'),('b'),('c'),('e')) Table1 (FC) UNION SELECT FC FROM (VALUES('a'),('b'),…
使用连接SQL 1999SELECT table1.column, table2.columnFROM table1[NATURAL JOIN table2] |[JOIN table2 USING (column_name)] |[JOIN table2 ON (table1.column_name = table2.column_name)]|[LEFT|RIGHT|FULL OUTER JOIN table2 ON (table1.column_name = table2.column_n…
使用INSERT语句INSERT INTO table [(column [, column...])]VALUES (value [, value...]); INSERT INTO departments(department_id, department_name, manager_id, location_id)VALUES (70, 'Public Relations', 100, 1700);字符和日期需要用单引号 INSERT INTO employeesVALUES (114,…
IList<string> s1 = new List<string>() { "One", "Two", "Three", "Two", "Three", "wjire" }; IList<string> s2 = new List<string>() { "www", "Tssswo", &quo…
重建scott用户@?/rdbms/admin/utlsampl.sql@--执行?--$ORACLE_HOME 字符区分大小写:SELECT last_name, job_id, department_idFROM employeesWHERE last_name = 'Whalen' ; 使用字符函数:SELECT last_name, job_id, department_idFROM employeesWHERE upper(last_name) = 'WHALEN' ; SELECT…
第一节课: 启动数据库并且使用特定用户连接:su - oracle; 启动sqlplus并且使用sys连接:conn / as sysdba; 启动数据库:startup; 解锁用户:alter user hr identified by hr;alter user hr account unlock; 使用hr连接:conn hr/hr;select * from tab;desc employees;select * from departments; 开发工具:plsql develope…
大小写转换函数LOWER('SQL Course') = sql courseUPPER('SQL Course') = SQL COURSEINITCAP('SQL Course') = Sql CourseSELECT employee_id, last_name, department_idFROM employeesWHERE last_name = 'higgins'; SELECT employee_id, last_name, department_idFROM employees…
隐式转换select * from emp where empno='7788'字符(char,varchar2)转换为数字(number)或日期(date)数字或日期转换为字符 显式转换字符转换为数字或日期(TO_NUMBER, TO_DATE)数字或日期转换为字符(TO_CHAR) TO_CHAR(date, 'format_model')select sysdate, to_char(sysdate,'yyyy') yyyy, to_char(sysdate,'year') year,fr…