1. --oracle 练习;
  2. /**************************************************PL/SQL编程基础***************************************************************/
  3. --firstday
  4. --》》》数据类型
  5. -- Create table
  6. create table T_CSCUSTOMER
  7. (
  8. CUST_NO VARCHAR2(12) primary key not null,
  9. PERSON_ID VARCHAR2(12),
  10. GROUP_NO VARCHAR2(12),
  11. CUST_ADDRESS_ID VARCHAR2(20),
  12. ORGANISEID VARCHAR2(10),
  13. CUST_NAME VARCHAR2(128),
  14. CUST_TYPE VARCHAR2(2),
  15. SERVE_PASSWORD VARCHAR2(128),
  16. REGIONCODE VARCHAR2(4),
  17. OPERATOR VARCHAR2(16),
  18. OPENDATE DATE,
  19. REMARK VARCHAR2(500),
  20. ADDRESS VARCHAR2(256),
  21. CUST_KIND VARCHAR2(4),
  22. LINKMAN VARCHAR2(64),
  23. LINKPHONE VARCHAR2(64),
  24. LINKMOBILE VARCHAR2(64),
  25. COMPANY_ID VARCHAR2(10),
  26. INSTALL_ADDRESS VARCHAR2(256)
  27. )
  28.  
  29. set serveroutput on
  30.  
  31. --%TYPE类型
  32. --SQL>
  33. declare
  34. var_ename t_cscustomer.cust_name%type;
  35. var_phone t_cscustomer.linkphone%type;
  36.  
  37. begin
  38. SELECT cust_name,linkphone
  39. into var_ename,var_phone
  40. from t_cscustomer
  41. where cust_no='';
  42. dbms_output.put_line(var_ename||'的电话是:'||var_phone);
  43. end;
  44. /
  45.  
  46. --SQL>
  47. declare
  48. var_ename varchar2(200);
  49. var_phone varchar2(200);
  50.  
  51. begin
  52. SELECT cust_name,linkphone
  53. into var_ename,var_phone
  54. from t_cscustomer
  55. where cust_no='';
  56. dbms_output.put_line(var_ename||'的电话是:'||var_phone);
  57. end;
  58. /
  59.  
  60. --record类型
  61. --SQL>
  62. declare
  63. type emp_type is record
  64. (
  65. var_ename varchar2(20),
  66. var_phone varchar2(20),
  67. var_sal varchar2(200)
  68. );
  69. empinfo emp_type;
  70. begin
  71. select cust_name,linkphone,address into empinfo from t_cscustomer where cust_no='';
  72. dbms_output.put_line('雇员'||empinfo.var_ename||'的电话是'||empinfo.var_phone||'、地址是'||empinfo.var_sal);
  73. end;
  74. /
  75.  
  76. --%rowtype类型
  77. --SQL>
  78. declare
  79. rowVar_emp t_cscustomer%rowtype;
  80. begin
  81. SELECT * into rowVar_emp FROM t_cscustomer where cust_no='';
  82. /*输出信息*/
  83. dbms_output.put_line('雇员'||rowVar_emp.cust_name||'的电话是'||rowVar_emp.linkphone||'、地址是'||rowVar_emp.address);
  84. end;
  85. /
  86.  
  87. --变量 、常量
  88. var_countryname varchar2(50):='中国';
  89. con_day constant integer:=365;
  90.  
  91. --secondday
  92. --》》》流程控制
  93. --if
  94. --SQL>
  95. declare
  96. var_name1 varchar2(20);
  97. var_name2 varchar2(20);
  98. begin
  99. var_name1:='East';
  100. var_name2:='xiaoke';
  101. if length(var_name1) < length(var_name2) then
  102. dbms_output.put_line('字符串“'||var_name1||'”的长度比字符串“'||var_name2||'”的长度小');
  103. end if;
  104. end;
  105. /
  106. --if elseif
  107. --SQL>
  108. declare
  109. num_age int :=55;
  110. begin
  111. if num_age>=56 then
  112. dbms_output.put_line('您可以申请退休了');
  113. elsif num_age<56 then
  114. dbms_output.put_line('您小于56岁,不可以申请退休!');
  115. else
  116. dbms_output.put_line('对不起,年龄不合法!');
  117. end if;
  118. end;
  119. /
  120.  
  121. --SQL>
  122. declare
  123. num_age int :=55;
  124. aboutinfo varchar2(50);
  125. begin
  126. if num_age>=56 then
  127. aboutinfo:='您可以申请退休了';
  128. elsif num_age<56 then
  129. aboutinfo:='您小于56岁,不可以申请退休!';
  130. else
  131. aboutinfo:='对不起,年龄不合法!';
  132. end if;
  133. dbms_output.put_line(aboutinfo);
  134. end;
  135. /
  136.  
  137. --case when
  138. --SQL>
  139. declare
  140. season int:=3;
  141. aboutinfo varchar2(50);
  142. begin
  143. case season
  144. when 1 then
  145. aboutinfo := season||'季度包括1、2、3 月份';
  146. when 2 then
  147. aboutinfo := season||'季度包括4、5、6 月份';
  148. when 3 then
  149. aboutinfo := season||'季度包括7、8、9 月份';
  150. when 4 then
  151. aboutinfo := season||'季度包括10、11、12 月份';
  152. else
  153. aboutinfo := season||'季度不合法';
  154. end case;
  155. dbms_output.put_line(aboutinfo);
  156. end;
  157. /
  158.  
  159. --》》》循环语句
  160. --loop语句 一直运行到exit when end_condition_exp true时退出
  161. declare
  162. sum_i int:=0;
  163. i int:=0;
  164. begin
  165. loop
  166. i:=i+1;
  167. sum_i :=sum_i + i;
  168. exit when i = 100;
  169. end loop;
  170. dbms_output.put_line('前100个自然数的和是:'||sum_i);
  171. end;
  172. /
  173. --while 语句
  174. declare
  175. sum_i int := 0;
  176. i int :=0;
  177. begin
  178. while i<100 loop
  179. i:=i+1;
  180. sum_i:=sum_i+i;
  181. end loop;
  182. dbms_output.put_line('前100个自然数的和是:'||sum_i);
  183. end;
  184. /
  185. --for 语句
  186. declare
  187. sum_i int:=0;
  188. begin
  189. for i in reverse 1..100 loop -- reverse 表示i100递减
  190. sum_i:= sum_i+i;
  191. end loop;
  192. dbms_output.put_line('前100个自然数的和是:'||sum_i);
  193. end;
  194. /
  195.  
  196. --》》》游标
  197. /*
  198. 游标属性:
  199. cur_tmp%found 至少影响到一行数据为true;
  200. cur_tmp%notfound 与%found相反
  201. cur_tmp%rowcount 返回受SQL语句影响的行数
  202. cur_tmp%isopen 游标打开时为true
  203. */
  204. --显示cursor
  205. set serveroutput on
  206. declare
  207. cursor cur_emp(var_name in varchar2:='lili')
  208. is select cust_no,cust_name,address
  209. from t_cscustomer
  210. where cust_name like var_name||'%';
  211. type record_emp is record
  212. (
  213. var_empno t_cscustomer.cust_no%type,
  214. var_empname t_cscustomer.cust_name%type,
  215. var_empaddress t_cscustomer.address%type
  216. );
  217. emp_row record_emp;
  218. begin
  219. DBMS_OUTPUT.ENABLE(buffer_size => null); --表示输出buffer不受限制
  220. open cur_emp('刘');
  221. fetch cur_emp into emp_row;
  222. while cur_emp%found loop
  223. dbms_output.put_line(emp_row.var_empname||'的编号是'||emp_row.var_empno||',地址是'||emp_row.var_empaddress);
  224. fetch cur_emp into emp_row;
  225. end loop;
  226. close cur_emp;
  227. end;
  228. /
  229.  
  230. --for 中使用cursor 不用进行打开游标、读取游标、关闭游标 oracle内部自动完成
  231. declare
  232. type emp_type is record
  233. (
  234. var_ename t_cscustomer.cust_name%type,
  235. var_phone t_cscustomer.linkphone%type,
  236. var_sal t_cscustomer.address%type
  237. );
  238. empinfo emp_type;
  239. cursor cur_emp
  240. is
  241. select cust_name var_ename,linkphone var_phone,address var_sal from t_cscustomer where address like '%招南%0402室%';
  242. begin
  243. DBMS_OUTPUT.ENABLE(buffer_size => null); --表示输出buffer不受限制
  244. --open cur_emp;
  245. --fetch cur_emp into empinfo;
  246. --dbms_output.put_line('共有数据'||cur_emp%rowcount||'条');
  247. for empinfo in cur_emp loop
  248. dbms_output.put_line('雇员'||empinfo.var_ename||'的电话是'||empinfo.var_phone||'、地址是'||empinfo.var_sal);
  249. end loop;
  250. end;
  251. /
  252.  
  253. declare
  254. cursor cur_emp
  255. is
  256. select cust_name var_ename,linkphone var_phone,address var_sal from t_cscustomer where address like '%招南%0402室%';
  257. begin
  258. DBMS_OUTPUT.ENABLE(buffer_size => null); --表示输出buffer不受限制
  259. for empinfo in cur_emp loop
  260. dbms_output.put_line('雇员'||empinfo.var_ename||'的电话是'||empinfo.var_phone||'、地址是'||empinfo.var_sal);
  261. end loop;
  262. end;
  263. /
  264.  
  265. begin
  266. DBMS_OUTPUT.ENABLE(buffer_size => null); --表示输出buffer不受限制
  267. for empinfo in (select cust_name var_ename,linkphone var_phone,address var_sal from t_cscustomer where address like '%招南%0402室%') loop
  268. dbms_output.put_line('雇员'||empinfo.var_ename||'的电话是'||empinfo.var_phone||'、地址是'||empinfo.var_sal);
  269. end loop;
  270. end;
  271. /
  272.  
  273. --》》》异常处理
  274. /*
  275. 预定义异常
  276. 自定义异常
  277. */
  278. --预定义异常
  279. declare
  280. var_empno t_cscustomer.cust_no%type;
  281. var_empname t_cscustomer.cust_name%type;
  282. begin
  283. select cust_no,cust_name into var_empno,var_empname from t_cscustomer where cust_no like '00%';
  284. if sql%found then
  285. dbms_output.put_line('雇员编号:'||var_empno||'、名称:'||var_empname);
  286. end if;
  287. exception
  288. when too_many_rows then
  289. dbms_output.put_line('返回记录超过一行');
  290. when no_data_found then
  291. dbms_output.put_line('无数据记录');
  292. end;
  293. /
  294. --自定义异常
  295. declare
  296. primary_iterant exception;--定义一个异常变量
  297. pragma exception_init(primary_iterant,-00001);--关联错误号和异常变量名
  298. begin
  299. insert into dept_tmp values('','综合部','北京');
  300. dbms_output.put_line('采用默认值插入dept_tmp成功!');
  301. exception
  302. when primary_iterant then
  303. dbms_output.put_line('主键不允许重复!');
  304. end;
  305. /
  306.  
  307. /**************************************************存储过程、函数、触发器、包***************************************************************/
  308. --》》》存储过程
  309. --查看错误
  310. show errors;
  311.  
  312. --创建或替换pro_insertTmp
  313. drop table dept_tmp;
  314. create table dept_tmp(
  315. DEPT_NO VARCHAR2(12) primary key not null,
  316. DEPT_NAME VARCHAR2(50),
  317. LOCATION VARCHAR2(200)
  318. );
  319. create or replace procedure pro_insertTmp is
  320. begin
  321. insert into dept_tmp values(1,'市场拓展部','join');
  322. commit;
  323. dbms_output.put_line('插入dept_tmp新记录成功');
  324. end pro_insertTmp;
  325. /
  326. --执行pro_insertTmp
  327. --execurte pro_insertTmp;
  328. exec pro_insertTmp;
  329.  
  330. --程序块中调用pro_insertTmp
  331. set serverout on
  332. begin
  333. pro_insertTmp
  334. end;
  335. /
  336.  
  337. --third day2015-02-03
  338. /**存储过程参数过程包括:in 输入参数、out 输出参数、in out可被修改的输入参数,并作为输出参数**/
  339. -->>in
  340. create or replace procedure pro_insertDept(v_deptno in varchar2,v_deptname in varchar2,v_loc in varchar2) is
  341. begin
  342. insert into dept_tmp values(v_deptno,v_deptname,v_loc);
  343. commit;
  344. dbms_output.put_line('通过in参数插入dept成功!');
  345. end pro_insertDept;
  346. /
  347.  
  348. --不按顺序传入参数,指定参数值
  349. begin
  350. pro_insertDept(v_deptname=>'采购部',v_loc=>'成都',v_deptno=>'');
  351. end;
  352. /
  353. --按顺序传入参数
  354. begin
  355. pro_insertDept('','市场部','深圳');
  356. end;
  357. /
  358. --混合传入参数
  359. begin
  360. pro_insertDept('',v_loc=>'成都',v_deptname=>'工程部');
  361. end;
  362. /
  363.  
  364. -->>out
  365. create or replace procedure pro_selectDept(v_deptno in varchar2,v_deptname out dept_tmp.dept_name%type,v_loc out dept_tmp.location%type) is
  366. begin
  367. select dept_name,location into v_deptname,v_loc from dept_tmp where dept_no=v_deptno;
  368. exception
  369. when no_data_found then
  370. dbms_output.put_line('该编号的部门不存在!');
  371. end pro_selectDept;
  372. /
  373.  
  374. set serveroutput on
  375. declare
  376. v_deptname dept_tmp.dept_name%type;
  377. v_loc dept_tmp.location%type;
  378. begin
  379. pro_selectDept('',v_deptname,v_loc);
  380. --if v_deptname = '' then
  381. dbms_output.put_line(v_deptname||'位于:'||v_loc);
  382. --end if;
  383. end;
  384. /
  385.  
  386. --执行
  387. variable v_deptname varchar2(50);
  388. variable v_loc varchar2(50);
  389. exec pro_selectDept('',:v_deptname,:v_loc);
  390. print v_deptname v_loc;
  391. select :v_deptname,:v_loc from dual;
  392.  
  393. -->> in out
  394. create or replace procedure pro_square(num in out number,flag in boolean) is
  395. i int:=2;
  396. begin
  397. if flag then
  398. num := power(num,i); --计算平方
  399. else
  400. num := sqrt(num); --计算平方根
  401. end if;
  402. end pro_square;
  403. /
  404.  
  405. declare
  406. n_number number;
  407. n_tmp number;
  408. b_flag boolean;
  409. begin
  410. b_flag:=false;
  411. n_tmp:=3;
  412. n_number:=n_tmp;
  413. pro_square(n_number,b_flag);
  414. if b_flag then
  415. dbms_output.put_line(n_tmp||'的平方是:'||n_number);
  416. else
  417. dbms_output.put_line(n_tmp||'的平方根是:'||n_number);
  418. end if;
  419. end;
  420. /
  421.  
  422. --in 参数默认值
  423. create or replace procedure pro_insertDeptDefault(v_deptno in varchar2,v_deptname in varchar2 default '综合部',v_loc in varchar2 default '北京') is
  424. primary_iterant exception;--定义一个异常变量
  425. pragma exception_init(primary_iterant,-00001);--关联错误号和异常变量名
  426. begin
  427. insert into dept_tmp values(v_deptno,v_deptname,v_loc);
  428. commit;
  429. dbms_output.put_line('采用默认值插入dept_tmp成功!');
  430. exception
  431. when primary_iterant then
  432. dbms_output.put_line('主键不允许重复!');
  433. end pro_insertDeptDefault;
  434. /
  435. --指定名称传值
  436. declare
  437. row_dept dept_tmp%rowtype;
  438. begin
  439. pro_insertDeptDefault('',v_loc => '太原');
  440. select * into row_dept from dept_tmp where dept_no='';
  441. dbms_output.put_line('部门名称:'||row_dept.dept_name||',位于:'||row_dept.location);
  442. exception
  443. when no_data_found then
  444. dbms_output.put_line('未找到相关的数据!');
  445. end;
  446. /
  447.  
  448. drop table t_emp;
  449. create table t_emp(
  450. emp_no number primary key not null,
  451. emp_name varchar2(20),
  452. age number,
  453. sal number,
  454. job varchar2(20),
  455. dept_no number,
  456. address varchar2(200),
  457. hiredate date
  458. );
  459. insert into t_emp values(1,'王力',22,9000,'会计',3,'深圳市北京路奥巴马号',sysdate);
  460. --》》》函数
  461. create or replace function get_avg_pay(num_deptNo number) return number is
  462. num_avg_pay number;
  463. begin
  464. select avg(sal) into num_avg_pay from t_emp where dept_no=num_deptNo;
  465. return(round(num_avg_pay,2));
  466. exception
  467. when no_data_found then
  468. dbms_output.put_line('该部门编号的员工不存在');
  469. return(0);
  470. end get_avg_pay;
  471. /
  472.  
  473. --程序块中调用函数
  474. declare
  475. avg_pay number;
  476. begin
  477. avg_pay:=get_avg_pay(3);
  478. dbms_output.put_line('编号为3的部门,平均工资是:'||avg_pay);
  479. end;
  480. /
  481.  
  482. --删除函数
  483. drop function get_avg_pay;
  484.  
  485. --》》》触发器
  486. --语法格式
  487. create or replace trigger tri_name
  488. [before|after|instead of] tri_event
  489. on table_name|view_name|user_name|db_name
  490. [for each row][when tri_condition]
  491. begin
  492. plsql_sentences;
  493. end tri_name;
  494. /
  495.  
  496. create table dept_log(
  497. operate_tag varchar2(10),
  498. operate_time date
  499. );
  500. --语句级触发器
  501. create or replace trigger tri_dept
  502. before insert or update or delete
  503. on dept_tmp
  504. declare
  505. v_tag varchar2(20);
  506. begin
  507. if inserting then
  508. v_tag:='插入';
  509. elsif updating then
  510. v_tag:='修改';
  511. elsif deleting then
  512. v_tag:='删除';
  513. end if;
  514. insert into dept_log values(v_tag,sysdate);
  515. end tri_dept;
  516. /
  517. insert into dept_tmp values(6,'业务咨询部','长春');
  518. update dept_tmp set location='沈阳' where dept_no='';
  519. delete from dept_tmp where dept_no='';
  520.  
  521. --行级触发器
  522. create table t_goods(
  523. id int primary key not null,
  524. good_name varchar2(50)
  525. );
  526.  
  527. create sequence seq_goods_id;
  528.  
  529. --:new.id--列标识符,新值标识符用于标识当前行某个列的新值“:new.column_name”,通常在insertupdate语句中使用
  530. --:old.id--列标识符,原值标识符用于标识当前行某个列的原始值“:new.column_name”,通常在deleteupdate语句中使用
  531. create or replace trigger tri_insert_goods
  532. before insert
  533. on t_goods
  534. for each row
  535. begin
  536. select seq_goods_id.nextval into :new.id from dual;
  537. end;
  538. /
  539.  
  540. insert into t_goods(good_name) values('苹果');
  541. insert into t_goods(id,good_name) values(9,'桃子');
  542.  
  543. --替换触发器
  544. --替换触发器定义在视图(一种数据库对象)上,而不是定义在表上。
  545. create view view_emp_dept
  546. as select emp_no,emp_name,dept_tmp.dept_no,dept_name,job,hiredate from t_emp,dept_tmp where t_emp.dept_no=dept_tmp.dept_no;
  547.  
  548. create or replace trigger tri_insert_view
  549. instead of insert
  550. on view_emp_dept
  551. for each row
  552. declare
  553. row_dept dept_tmp%rowtype;
  554. begin
  555. select * into row_dept from dept_tmp where dept_no=:new.dept_no;
  556. if sql%notfound then
  557. insert into dept_tmp(dept_no,dept_name) values(:new.dept_no,:new.dept_name);
  558. end if;
  559. insert into t_emp(emp_no,emp_name,dept_no,job,hiredate) values (:new.emp_no,:new.emp_name,:new.dept_no,:new.job,:new.hiredate);
  560. end tri_insert_view;
  561. /
  562.  
  563. --rollback不能再触发器中使用
  564. create or replace trigger tri_insert_view2
  565. instead of insert
  566. on view_emp_dept
  567. for each row
  568. declare
  569. row_dept dept_tmp%rowtype;
  570. begin
  571. select * into row_dept from dept_tmp where dept_no=:new.dept_no;
  572. if sql%notfound then
  573. insert into dept_tmp(dept_no,dept_name) values(:new.dept_no,:new.dept_name);
  574. end if;
  575. insert into t_emp(emp_no,emp_name,dept_no,job,hiredate) values (:new.emp_no,:new.emp_name,:new.dept_no,:new.job,:new.hiredate);
  576. exception
  577. --when no_data_found then
  578. --dbms_output.put_line('部门表中未找到相对应的部门编号');
  579. --rollback;
  580. end tri_insert_view;
  581. /
  582.  
  583. --若部门中没有编号10,会报错
  584. insert into view_emp_dept(emp_no,emp_name,dept_no,dept_name,job,hiredate) values (8888,'东方',10,'ACCOUNTING','CASHIER',sysdate);
  585. commit;
  586.  
  587. select * from view_emp_dept where emp_no=8888;
  588.  
  589. --用户事件触发器
  590. create table t_ddl_oper_log(
  591. db_obj_name varchar2(20),
  592. db_obj_type varchar2(20),
  593. oper_action varchar2(20),
  594. oper_user varchar2(20),
  595. oper_date date
  596. );
  597.  
  598. create or replace trigger tri_ddl_oper
  599. before create or drop or alter
  600. on liulei.schema
  601. begin
  602. insert into t_ddl_oper_log values(ora_dict_obj_name,ora_dict_obj_type,ora_sysevent,ora_login_user,sysdate);
  603. end;
  604. /
  605. create table t_test(id number);
  606. create view view_test as select emp_no,emp_name from t_emp;
  607. drop view view_test;
  608. select * from t_ddl_oper_log;
  609.  
  610. --》》》程序包
  611. --语法 规范
  612. create or replace package pack_name is
  613. [declare_variable];
  614. [declare_type];
  615. [declare_cursor];
  616. [declare_function];
  617. [declare_procedure];
  618. end [pack_name];
  619.  
  620. --创建一个程序包的“规范”,不包声明体的主体部分
  621. create or replace package pack_emp is
  622. function fun_avg_sal(num_deptno number) return number;--获取指定部门的平均工资
  623. procedure pro_regulate_sal(var_job varchar2,num_proportion number);--按照指定比例上调指定职务的工资
  624. end pack_emp;
  625. /
  626.  
  627. --语法 程序包主体
  628. create or replace package body pack_name is
  629. [inner_variable]
  630. [cursor_body]
  631. [function_title]
  632. {
  633. begin
  634. fun_plsql;
  635. [exception]
  636. [dowith_sentences;]
  637. end [fun_name]
  638. }
  639. [procedure_title]
  640. {
  641. begin
  642. pro_plsql;
  643. [exception]
  644. [dowith_sentences;]
  645. end [pro_name]
  646. }
  647. ...
  648. end [pack_name]
  649.  
  650. create or replace package body pack_emp is
  651. function fun_avg_sal(num_deptno number) return number is
  652. num_avg_sal number;
  653. begin
  654. select avg(sal) into num_avg_sal from t_emp where dept_no=num_deptno;
  655. return(num_avg_sal);
  656. exception
  657. when no_data_found then
  658. dbms_output.put_line('该部门编号不存在雇员记录!');
  659. return 0;
  660. end fun_avg_sal;
  661.  
  662. procedure pro_regulate_sal(var_job varchar2,num_proportion number) is
  663. begin
  664. update t_emp set sal=sal*(1+num_proportion) where job=var_job;
  665. end pro_regulate_sal;
  666. end pack_emp;
  667. /
  668.  
  669. --调用包
  670. set serveroutput on
  671. declare
  672. num_deptno t_emp.dept_no%type;
  673. var_job t_emp.job%type;
  674. num_avg_sal t_emp.sal%type;
  675. num_proportion number;
  676. begin
  677. num_deptno:=5;
  678. num_avg_sal:=pack_emp.fun_avg_sal(num_deptno);
  679. dbms_output.put_line(num_deptno||'号部门的平均工资是:'||num_avg_sal);
  680.  
  681. var_job := 'SALEMAN';
  682. num_proportion:=0.1;
  683. pack_emp.pro_regulate_sal(var_job,num_proportion);
  684. end;
  685. /

oracle PLSQL基础学习的更多相关文章

  1. Oracle SQL 基础学习

    oracel sql 基础学习 CREATE TABLE USERINFO ( ID ,) PRIMARY KEY, USERNAME ), USERPWD ), EMAIL ), REDATE DA ...

  2. Oracle 数据库 基础学习 (一) SQL基本知识

    Oracle 从零开始,不知所措.要掌握一种技能,最好的方式是先学会怎么使用它,然后再深入学习,先有样子,再有技术.   一,什么是数据库? 为什么需要数据库? 数据库实质上是一个信息的列表,或者是一 ...

  3. Oracle 数据库基础学习 (三) Oracle 四个表结构

    Oracle 四个表的 emp dept  salgrade  bunus 的结构,记住有利于后期SQL语句的学习 雇员表(emp) No. 字段 类型 描述 1 empno NUMBER(4) 表示 ...

  4. PLSQL基础学习-文字

    --oracle 练习: /********************PL/SQL编程基础*******************************/ --firstday -->>&g ...

  5. Oracle 数据库基础学习 (二) 学习小例子:创建一个表,记录商品买卖的情况

      运行环境:Oracle database 11g + PL/SQL Developer ex: --创建一个表 create table plspl_test_product( --加入not n ...

  6. Oracle 数据库基础学习 (八) PL/SQL综合练习

    1.定义游标:列出每个员工的姓名.部门名称并编程显示第10个到第20个记录. declare cursor zemp_cursor is (select temp.ename, temp.dname ...

  7. Oracle 数据库基础学习 (七) SQL语句综合练习

    一.多表查询综合练习 1.  列出高于在30部门工作的所有人员的薪金的员工的姓名.部门名称.部门编号.部门人数 分析: 需要的员工信息: |-emp表:姓名.部门编号 |-dept表:部门名称.部门编 ...

  8. Oracle 数据库基础学习 (六) 子查询

    子查询在一个select中出现多个嵌套查询语句 1.在where子句中使用子查询(一般返回"单行单列" "单行多列" "多行单列"(可以提供 ...

  9. Oracle 数据库基础学习 (五) 多表查询

    多表查询:查询结果需要用到两个或者以上表,此时需要多表连接,产生多表查询 1.内连接(等值连接) 示例:将两个表内容连接显示 select * from dept d, emp e where d.d ...

随机推荐

  1. sql 中的 STUFF()使用说明,以及千分位的常用函数

    STUFF 删除指定长度的字符并在指定的起始点插入另一组字符. 语法 STUFF ( character_expression , start , length , character_express ...

  2. 15个Spring的核心注释示例

    众所周知,Spring DI和Spring IOC是Spring Framework的核心概念.让我们从org.springframework.beans.factory.annotation和org ...

  3. ie6遮罩层兼容 100%高度的实现

    .black { position:absolute;width:100%;height:100%;opacity:0.5;filter:alpha(opacity=50);background:#0 ...

  4. [Windows Azure] Management REST API Reference

    Management REST API Reference 27 out of 42 rated this helpful - Rate this topic The SQL Database Man ...

  5. c++中数据表如何转成业务实体--map和结构体的相互转换

    应用场景:如何把数据库表中的一行转换成一个业务实体结构体,c#和java中都有实体框架,表到实体的转换很方便,c++中缺少这些框架,但是有一些折中的办法去做.其实问题的本质是:map如何转成结构体. ...

  6. 每日英语:Can Robots Better Spot Terrorists at Airports?

    Next to have their jobs automated: airport-security screeners? Aviation and government authorities a ...

  7. Android 编程下背景图片适配工具类

    package cn.sunzn.util; import android.content.Context; import android.graphics.Bitmap; import androi ...

  8. 【Java工具方法】给集合按数量分组

    有时候需要给集合(如List)按数量分组,比如全集太大时,需要分批处理:或效率有点低,分批并发处理.于是,写了个将List按数量分组的方法. package controller; import ja ...

  9. 关于 android receiver

    可以在代码文件中声明一个receiver,也可以在manifest中声明一个,前者中的receiver只有在该activity launch起来以后才会监听其所感兴趣的事件,而如果在androidMa ...

  10. python版本坑:md5例子(python2与python3中md5区别)

    对于一些字符,python2和python3的md5加密出来是不一样的. Python2 和Python3MD5加密 # python2.7 pwd = "xxx" + chr(1 ...