1. 程式人生 > >oracle資料庫學習記錄(持續更新中...)

oracle資料庫學習記錄(持續更新中...)

--------------------------------------------day10-------------------------------------------------
--1.認識PL/SQL的函式
--2.建立包和包體
--3.PL/SQL變數的型別


--1.認識PL/SQL的函式
--問題:輸入一個僱員姓名,返回年薪
--函式型別寫在函式名後邊
create or replace function sp_func(spName varchar2) return number is
yearSal number(7,2);
begin
  select sal*12+nvl(comm,0)*12 into yearSal from emp where ename=spName;
  return yearSal;
end;


--總結
--語法:
/*create [or replace] function 函式名(引數1 型別1,引數2 型別2,....) return 返回值型別 is
  --變數,常量和遊標的定義
  begin
    --執行部分
    exception
      --異常處理部分
  end
*/
--呼叫函式1  var全域性變數
var income number;                   --定義全域性變數:var 變數名 變數型別
call sp_func('SCOTT') into:income;   --全域性變數賦值:call 函式 into:全域性變數名
print income;                        --列印全域性變數:print 全域性變數名


--呼叫函式2
select sp_func('SCOTT') from dual;


--包:組織管理過程和函式的一種機制,主要有兩部分組成:包規範和包體
--包裡面主要是宣告一下過程和函式,過程和函式的實現放在包體中
--問題:建立一個包,包含一個過程,包含一個函式,
--------過程:輸入員工姓名,新的工資,更新員工工資
--------函式:輸入員工姓名,計算員工工資
--建立包:只是宣告過程和函式
create or replace package sp_package is
  procedure update_sal(name emp.ename%type,newSal emp.sal%type);
  function annual_income(name emp.ename%type) return number;
end;
--總結
--語法
/*
create [or replace] package 包名 is
  過程1宣告;
  過程2宣告;
  ...
  函式1宣告;
  函式2宣告;
  ...
end;
*/
--建立包體:過程和函式的實現
create or replace package body sp_package is
  procedure update_sal(name emp.ename%type,newSal emp.sal%type) is
    begin
      update emp set sal=newSal where ename=name;
    end;
  function annual_income(name emp.ename%type) return number is
    yearSal number(7,2);
    begin
      select sal*12+nvl(comm,0)*12 into yearSal from emp where ename=name;
      return yearSal;
    end;
end;
--建立包體語法:
/*
create [or replace] package body 包名 is
       過程1實現體;
       過程2實現體;
       ...
       函式1實現體
       函式2實現體
       ...
end
*/


--包中過程和函式的呼叫:包名.過程名  或者  包名.函式名
exec sp_package.update_sal('SCOTT',4500);


var income number;
call sp_package.annual_income('SCOTT') into:income;
print income;


select sp_package.annual_income('SCOTT') from dual;


--觸發器:觸發器是指隱含執行的儲存過程,當定義觸發器時,必須置頂觸發事件和觸發操作。
--常見的觸發事件包括:insert,update,delete語句。
--觸發器是一個PL/SQL塊,可以通過create trigger來建立


--PL/SQL變數:標量型別,複合型別,參照型別,lob(large object)型別


--標量型別: 基本型別
--變數名[constant] 資料型別[not null] [:=值]或者[default 值];
--%type:標量型別的一種
--案例:
/*
定義一個變長的字串:v_ename varchar2(20);
定義一個小數:v_yearsal number(7,2);
定義一個小數,給初始值為3.14:v_sal number(3,2):=3.14;
定義一個常量PI給預設值為3.14:PI constant number(3,2):=3.14;
定義一個日期型別:v_hiredate date;
定義一個布林型別:v_invid boolean not null default false;
*/
--編寫一個PL/sql塊,輸入員工編號,顯示員工的姓名和工資,以及個人所得稅(稅率0.05)
declare
v_tax_rate constant number(3,2):=0.05;
v_ename emp.ename%type;
v_sal emp.sal%type;
v_personal_tax number(7,2); 
begin
  select ename,sal into v_ename,v_sal from emp where empno=&no;
  v_personal_tax:=v_sal*v_tax_rate;
  dbms_output.put_line('姓名:'||v_ename||'工資:'||v_sal||'個人所得稅:'||v_personal_tax);
end;


--複合型別的一種:
--(1)PL/SQL的記錄型別
--(2)PL/SQL的表型別
--(3)巢狀表型別
--(4)varray型別
--PL/SQL的記錄型別:%rowtype 跟表的型別一致
--輸入一個員工編號,顯示該員工的所有資訊
declare 
v_emp emp%rowtype;
begin
  select * into v_emp from emp where empno=&no;
  dbms_output.put_line('姓名:'||v_emp.ename||'工作'||v_emp.job);
end;




----記錄型別:類似於結構體
declare 
type emp_record_type is record(name emp.ename%type,salary emp.sal%type,dept emp.deptno%type);
sp_record emp_record_type;
begin
  select ename,sal,deptno into sp_record from emp where empno=&no;
  dbms_output.put_line('姓名:'||sp_record.name||'工資:'||sp_record.salary||'部門:'||sp_record.dept);
end;




-----記錄型別的語法:
/*
type 型別名 is record(變數1 資料型別1,變數2 資料型別2....)
變數名 型別名;
*/




----PL/sql表型別
--表型別:類似於陣列
--定義表型別時:
---1.不定義表的大小,動態表  
---2.需要定義表中每個資料的型別
---3.表型別的下標可以為負,正
declare 
type emp_table_type is table of emp.ename%type index by binary_integer;
sp_table emp_table_type;
begin
  select ename into sp_table(-1) from emp where empno=&no;
  dbms_output.put_line('姓名:'||sp_table(-1));
end;


--表型別
/*
type 型別名 is table of 資料型別 index by binary_integer;
變數名 型別名
*/


--參照型別:遊標
---案例:輸入一個部門名稱,顯示該部門所有員工的姓名和工資
declare 
type sp_emp_cursor is ref cursor;
test_cursor sp_emp_cursor;
v_ename emp.ename%type;
v_sal emp.sal%type;
begin
  open test_cursor for select ename,sal from emp where deptno=&no;
  loop
    fetch test_cursor into v_ename,v_sal;
    exit when test_cursor%notfound;
    dbms_output.put_line('姓名:'||v_ename||'工資:'||v_sal);
  end loop;
  close test_cursor;
end;




--總結:
/*
(1)type sp_emp_cursor is ref cursor:   表示sp_emp_cursor是一個遊標型別
(2)test_cursor sp_emp_cursor;   定義一個遊標變數test_cursor,是sp_emp_cursor型別
(3)open test_cursor for 查詢語句
(4)fetch 遊標變數名 into 變數1,變數2
(5)exit when test_cursor%notfound   定義遊標迴圈退出條件
(6)close test_cursor  關閉遊標


*/
---寫法2:
declare 
curcor v_cursor is select ename,sal from emp where deptno=&no;
v_ename emp.ename%type;
v_sal emp.sal%type;
begin
  open v_cursor;
  loop
    fetch v_cursor into v_ename,v_sal;
    exit when v_cursor%notfound;
    dbms_output.put_line('姓名:'||v_ename||'工資:'||v_sal);
  end loop;
  close v_cursor;
end;
/*
cursor 遊標變數名 is 查詢語句
變數名 變數型別
.....
begin
  open 遊標變數
  fetch 遊標變數 into 變數1,變數2,....
  close 遊標變數
end
*/


--寫法3:
declare
cursor v_cursor is select ename,sal from emp where deptno=&no;
v_ename emp.ename%type;
v_sal emp.sal%type;
begin
  for v_cursors in v_cursor loop
    v_ename:=v_cursors.ename;
    v_sal:=v_cursors.sal;
    dbms_output.put_line('姓名:'||v_ename||'工資:'||v_sal);
  end loop;
end;
---for迴圈自動開啟關閉遊標
--------------------------------------------day11-------------------------------------------------
--1.Pl/SQL流程控制
--2.動態PL/SQL
--3.異常


--1.Pl/SQL流程控制
---------if else
--案例1 :編寫一個儲存過程,輸入一個僱員姓名,如果該員工工資低於2000,工資增加10%
create or replace procedure updateSal(spName varchar2) is
v_sal emp.sal%type;
begin
  select sal into v_sal from emp where ename=spName;
  if v_sal<2000 then
    update emp set sal=sal*1.1 where ename = spName;
  end if;
end;
--總結
 /*
 if...
 then...
 end if
 如果if後面條件滿足,則執行then後邊語句
 */


--案例2:編寫一個過程,輸入一個員工姓名,若獎金非空,加100,若為空或0,獎金設定為200
create or replace procedure updateComm(spName varchar2) is
v_comm emp.comm%type;
begin
  select nvl(comm,0) into v_comm from emp where ename = spName;
  if v_comm=0 then
    update emp set comm=200 where ename=spName;
  else
    update emp set comm=comm+100 where ename=spName;
  end if;
end;
--總結
/*
if...
then...
else...
end if


*/
--案例3,編寫一個儲存過程,如果職位是president工資加1000,manager +500 其他+200
create or replace procedure updateSal1(spName varchar2) is
v_job emp.job%type;
begin
  select job into v_job from emp where ename = spName;
  if v_job='PRESIDENT' then
    update emp set sal=sal+1000 where ename=spName;
  elsif v_job='MANAGER' then
    update emp set sal=sal+500 where ename=spName;
  else
    update emp set sal=sal+200 where ename=spName;
  end if;
end;
--總結
/*
if...
then...
elsif....
then....
else....
end if;
*/


---------loop  end loop
--案例4:建立一張表users,迴圈插入10條記錄
create table users(id number(3),
name varchar2(10));


create or replace procedure insertTable(spName varchar2) is
v_num number:=1;
begin
  loop
    insert into users values(v_num,spName);
    v_num:=v_num+1;
    exit when v_num=11;
  end loop;
end;
--總結:loop....end loop:首先定義一個迴圈變數,其次在loop和end loop之間一定要寫退出條件,否則死迴圈


--案例5:編寫一個儲存過程,可以輸入使用者名稱,並迴圈users中新增資料
create or replace procedure insertTable1(spName varchar2) is
v_num number:=11;
begin
    while v_num<=20 loop
       insert into users values(v_num,spName);
       v_num:=v_num+1;
  end loop;
end;
--總結:while 迴圈條件 loop 執行內容;迴圈控制語句;end loop  


--案例6:使用for迴圈


create or replace procedure insertTable2(spName varchar2) is
begin
    for i in 21..30 loop
       insert into users values(i,spName);
  end loop;
end;
--總結:for 迴圈變數 loop in 21..30 迴圈語句 end loop


--案例7 用三種迴圈語句實現1加到100
--(1)
declare 
v_counter number:=1;
v_sum number:=0;
begin
  loop
    v_sum:=v_sum+v_counter;
    v_counter:=v_counter+1;
    exit when v_counter=101;
  end loop;
  dbms_output.put_line('和是:'||v_sum);
end;


declare 
v_counter number:=1;
v_sum number:=0;
begin
  while v_counter<=100 loop
    v_sum:=v_sum+v_counter;
    v_counter:=v_counter+1;
  end loop;
  dbms_output.put_line('和是:'||v_sum);
end;




declare 
v_sum number:=0;
begin
  for i in 1..100 loop
    v_sum:=v_sum+i;
  end loop;
  dbms_output.put_line('和是:'||v_sum);
end;


--案例8:case語句,從鍵盤接受一個輸入,輸入A,輸出優秀,輸入B,輸出良好,輸入C輸出中等,
-------其他情況輸出不及格


declare 
v_grade char(5):=&grade;
begin
  case v_grade
    when 'A' then
      dbms_output.put_line('優秀');
    when 'B' then 
      dbms_output.put_line('良好');
    when 'C' then 
      dbms_output.put_line('中等');
    else  
      dbms_output.put_line('不及格');
  end case;
end;
--總結:
/*
 case 變數 
   when 值1 then
     執行語句1
   when 值2 then
     執行語句2
   ....
   else
     執行語句
 end case; 
*/
--**********************************
--2.動態SQL
--動態SQL:編譯期間SQL語句不確定,並且在執行時允許變化
--應用場合:要執行一個DDL語句時;需要增加程式的靈活性時,使用包DBMS_SQL動態執行SQL語句
--案例1:編寫SQL塊,建立一張test1表
begin
  execute immediate 'create table test1(id number(5),name varchar(10))';
end;
--總結:PL/SQL塊不能直接執行DDL語句,所以可以用動態的sql去執行
--execute immediate sql語句
declare 
stmt varchar2(150):='create table test1(id number(5),name varchar(10))';
begin 
  execute immediate stmt;
end;


--案例2:編寫一個PL/SQL塊,向test1中插入一條記錄,要求從鍵盤獲取
declare
v_id test1.id%type:=&id;
v_name test1.name%type:=&name;
begin
  execute immediate 'insert into test1 values(:1,:2)' using v_id,v_name;
end;
--總結:execute immediate sql語句 using 值1,值2,...;
--:1,:2佔位符  需要用到變數的地方用其代替


--案例3:查詢test1,從鍵盤接收id,輸出其姓名
declare
v_id test1.id%type:=&id;
v_name test1.name%type;
begin
  execute immediate 'select name from test1 where id=:1' into v_name using v_id;
  dbms_output.put_line('姓名是:'||v_name);
end;
--總結:execute immediate SQL語句 into 變數 using 變數
---(1)sql語句中並無into
---(2)where id=:1    :1是佔位符 表示在執行時需要一個值替代


--案例4:鍵盤輸入一個員工編號,查詢emp表中該員工的姓名和工資,工資小於2000,增加500,返回增加後工資
declare
v_empno emp.empno%type:=&no;
v_ename emp.ename%type;
v_sal emp.sal%type;
begin
  select ename,sal into v_ename,v_sal from emp where empno=v_empno;
  if v_sal<2000 then
    execute immediate 'update emp set sal=sal+500 where empno=:1 returning sal into :2' 
    using v_empno returning into v_sal;
  end if;
  dbms_output.put_line('新工資是:'||v_sal);
end;


--總結:execute immediate SQL 語句 useing 變數1 returning into 變數2
--update emp set sal=sal+500 where empno=:1 returning sal into :2 意思是更新sal,返回更新後的工資


--案例5:從鍵盤接受一個員工編號,刪除其資訊
declare
v_empno emp.empno%type:=&no;
begin
  execute immediate 'delete from emp where empno=:1' using v_empno; 
end;
--總結:佔位符在這裡可以是:num的形式


--**********************************
--3.異常處理
---編寫一個PL/SQL塊,查詢emp表中員工的工資
declare 
v_sal emp.sal%type;
begin
  select sal into v_sal from emp;
exception 
  when too_many_rows then
    dbms_output.put_line('找到多條記錄!:');
  when others then
     dbms_output.put_line('未知異常');
end;


---案例2:從鍵盤輸入有個empno,查詢該員工的工資,如果小於2000,報異常
--自定義異常
declare
v_sal emp.sal%type;
v_empno emp.empno%type:=&no;
myexp exception;
begin
  select sal into v_sal from emp where empno=v_empno;
  if v_sal<2000 then
    raise myexp;
  end if;
exception
  when myexp then
    dbms_output.put_line('漲工資!!!!!!!!!!');
end;
---總結
--(1)declare預定義一個異常
--(2)在執行部分觸發一個異常 raise myexp
--(3)在exception中處理異常




--------------------------------------------day12--------------------------------------------
--觸發器:當用戶登入或,退出,修改記錄,或者是對物件進行操作,進行ddl時,引起某個儲存過程的執行
--把這樣一個隱含的呼叫稱為觸發器
--1.當用戶登入時,希望可以自動記錄使用者名稱字和登入時間
--當用戶在週四或者非工作日對錶進行修改時,不允許這樣做
--當用戶刪除一條記錄時,希望可以將刪除記錄自動備份到另外一張表中


--解決方法:觸發器
--觸發器分類:dml觸發器(insert update delete)ddl觸發器,系統事件觸發器(登入、退出)


--案例1:建立一張my_emp表,給該表新增記錄,提示:新增一條資料
--語句級別觸發器:針對增刪改查只觸發一次操作
--建立表的語句
create table my_emp(id number(5),name varchar2(10));
--建立觸發器
create or replace trigger tri1
after insert on scott.my_emp
begin 
  dbms_output.put_line('新增一條資料');
end; 


insert into my_emp values(101,'hewie');


--案例2:在my_emp表修改id為101的員工資訊時,修改一次提示一次
--for each row 表名是一個行級觸發器:修改一行,觸發一次
create or replace trigger tri2
after update on scott.my_emp
for each row
begin
  dbms_output.put_line('修改一條資料');
end;


update my_emp set name='hewie' where id=101;


--建立觸發器的語法
/*
create [or replace] trigger trigger_name
before/after  insert/update/delete on table_name
[for each row]
[when condition]
begin
  --觸發的操作
end;
*/


--案例3:在刪除my_emp表中的記錄時,提示刪除一條記錄
create or replace trigger tri3
after delete on scott.my_emp
begin
  dbms_output.put_line('刪除一條資料');
end;


--案例4:在刪除記錄時,觸發報錯,不讓刪除
create or replace trigger tri4
before delete on scott.my_emp
begin
  raise_application_error(-20001,'禁止刪除');
end;
delete from my_emp where id=101;
-- raise_application_error是一個儲存過程,可以傳入兩個引數,
--第一個引數是錯誤號範圍:-20000到-20999,第二個引數是錯誤提示資訊


--案例5:為了禁止工作人員在週四刪除my_emp表中資訊,建立一個觸發器,完成這個操作
create or replace trigger tri5
before delete on scott.my_emp
begin
  if to_char(sysdate,'day')='星期四' then
    raise_application_error(-20002,'週四不允許刪除');
  end if;
end;


--案例6:禁止工作人員在週四修改員工資訊(insert update delete),不同操作儲存資訊不同
create or replace trigger tri6
before insert or update or delete on scott.my_emp
begin
  if to_char(sysdate,'day')='星期四' then
    case
      when inserting then
        raise_application_error(-20003,'就是不讓你新增');
      when updating then
        raise_application_error(-20004,'就是不讓你修改');
      when deleting then
        raise_application_error(-20004,'就是不讓你刪除');
    end case;
  end if;
end;
--當觸發器中同時包含多個觸發事件時,為了區分觸發事件,可以使用三個條件 inserting  updating deleting


--案例7:修改員工工資時,要求新工資必須比原工資高,建立一個觸發器,輸出新老工資
create or replace trigger tri7
before update on scott.emp
for each row
begin
  if :new.sal<:old.sal then
    raise_application_error(-20006,'工資不能低於原工資');
  else
    dbms_output.put_line('原來的工資是:'||:old.sal||'新的工資:'||:new.sal);
  end if;
end;


update emp set sal=2000 where ename='SMITH';
--:new update操作完成後的列的值
--:old update操作完成前的列的值


--案例8:編寫一個觸發器,當用戶刪除一張表的記錄時,自動將刪除的id和name備份到另一張表中
create table my_emp_bak as select * from my_emp where 1=2;


create or replace trigger tri8
before delete on scott.my_emp
for each row 
begin
  insert into my_emp_bak values(:old.id,:old.name);
end;


delete my_emp;
--禁用觸發器
alter trigger tri1 disable;
--啟用觸發器
alter trigger tri1 enable;
--刪除觸發器
drop trigger tri1;


--案例9:觸發器 控制員工的新工資不能低於的原來的工資但是也不能高於原來工資的20%
create or replace trigger tri9
before update on scott.emp
for each row
begin
  if :new.sal<:old.sal then
    raise_application_error(-20007,'工資不能低於原工資');
  elsif :new.sal>:old.sal*1.2 then
    raise_application_error(-20008,'工資不能高於原工資20%');
  else
    dbms_output.put_line('原來的工資是:'||:old.sal||'新的工資:'||:new.sal);
  end if;
end;


update emp set sal=5000 where ename='SMITH';




--oracle的系統觸發器:主要是針對oracle的系統事件的一個觸發器
--oracle定義的常用的系統事件:
--oracle_client_ip_address:返回客戶端的ip
--oracle_datebase_name:返回資料庫名
--oracle_login_user:返回登入使用者名稱
--ora_sysevent:返回觸發器的系統事件名
--ora_des_encrypted_password:返回加密後的密碼


--案例:為了記錄使用者登入和退出的時間,可以建立登入和退出的觸發器
create table logon_table(
username varchar2(10),
logon_time date,
logoff_time date,
address varchar2(20));


--建立登入觸發器
create or replace trigger logon
after logon on database
begin
  insert into logon_table(username,logon_time,address) 
  values(ora_login_user,sysdate,ora_client_ip_address);
end;


--建立退出觸發器
create or replace trigger logoff
before logoff on database
begin
  insert into logon_table(username,logoff_time,address) 
  values(ora_login_user,sysdate,ora_client_ip_address);
end;


--普通使用者沒有許可權建立系統觸發器


--ddl觸發器
--編寫一個觸發器,可以記錄使用者所進行的ddl操作
create table my_ddl_event(event varchar2(20),username varchar2(10),time date);


create or replace trigger ddl_tri
after ddl on scott.schema
begin
  insert into my_ddl_event values(ora_sysevent,ora_login_user,sysdate);
end;


--作業:建立一張學生表stu(id,name,birthdate),編寫一個觸發器,
--要求:如果學生年齡小於18歲,則不允許插入
create table stu(id number(5),name varchar2(10),birthdate date);


create or replace trigger tri_stu
before insert on scott.stu
for each row
begin
  dbms_output.put_line('年齡:'||floor(months_between(sysdate,:new.birthdate)/12));
  if floor((months_between(sysdate,:new.birthdate)/12))<18 then
    raise_application_error(-20010,'年齡低於18');
  end if;
end;


insert into stu values(123,'hewie',date'1990-05-12');

相關推薦

oracle資料庫學習記錄持續更新...

--------------------------------------------day10---------------------------------------------------1.認識PL/SQL的函式--2.建立包和包體--3.PL/SQL變數的型別--1.認識PL/SQL的函式--

51CTO-風哥-ORACLE學習計劃持續更新

第一模組(2018年11月10號-2018年12月8號) 學前指導(3節課)Linux(41節課)泛Unix作業系統(4節課)Oracle(97節課)(第5章1天、第6章1天、第7章1天、第8章2天、第9章2天、第10章2天、第11章3天、第12章3天、第13章2天)--》總共17天 學習時間 每天晚上2

CS231N作業記錄持續更新

ssi net tail 安裝ipython ipy 工作 href https 準備 參考資料:《 cs231n 課程作業 Assignment 1 》https://blog.csdn.net/zhangxb35/article/details/55223825 一

UVM_USERS_GUIDE學習彙總持續更新

1.overview 本章節通過典型的testbench架構和引入相關術語提供一個uvm的基本概述。 1.1 the typical uvm testbench architecture 1.1.1 uvm testbench UVM Testbench 例化了Des

Web學習筆記持續更新……

web伺服器: WebLogic是BEA公司的產品(收費); WebShphere是IBM公司的產品(商用收費),支援J2EE規範; Tomcat是APACHE公司的產品,支援全部JSP以及Servlet規範。 Tomcat官方網站:http://tomcat.apach

牛客網資料庫SQL實戰持續更新

1.查詢最晚入職員工的所有資訊 CREATE TABLE employees ( emp_no int(11) NOT NULL, birth_date date NOT NULL, first_name varchar(14) NOT NULL, l

《從樹莓派玩轉linux》讀書記錄持續更新

第五章 Linux Shell Linux通用查詢命令 命令名: 用途: 使用示例: 命令名: lscpu 用途: 用於檢視本機的CPU資訊 使用示例: 命令名: free 用途:

qtp 學習心得持續更新

目前在學習qtp,隨筆記錄一些內容,以防忘記。屬於初級入門階段,也許有更好更合適的方法,如果看到文章的童鞋,可以指出來,共同學習。 1、對於頁面內容顯示變化的物件,無法用名稱標識,目前採用描述性程式設計解決。 例如: 這種暱稱顯示。 用qtp物件庫抓取物件,為 ,剛開

前端開發工程師從入門到精通學習過程及資源總結持續更新

開發實戰 set dex 從入門到精通 main 知識 uno 基礎入門 易雲 職位名稱:前端開發工程師 學習概要:1、先了解基礎,html/css/JavaScript是基礎。html/css就是做靜態頁面的,javascript是做動態的。 2、學習框架:jQuery(

計算機專業學習資料總結~持續更新

今天為了複習離散數學,想著上網上找份課本答案(老師沒有給答案),結果那本書的配套題解的PDF大多數都是來自CSDN社群的,CSDN下載需要積分,要麼開通VIP,那VIP的費用實在不是我等窮學生所能支付得起的,我靈機一動便想到了萬能的淘寶賣家果然有賣CSND積分的,花了1塊3,很順利地下載了我想要的輔導書,之前

工作學習到的css用法持續更新

1.table中的內容水平垂直居中顯示 #id td{ vertical-align: middle; text-align: center; } <table id="id"></table> 2.div有最小高度,並且隨著內容的變化而變化

資料庫分庫分表持續更新

今天學習了資料庫分表分庫,感覺記錄下一些東西以便以後的檢視。 1、資料庫建立索引,可以加快表資料的查詢,但是過多的索引,會佔用大量的記憶體,維護難度較大,因為索引底層的演算法是B-tree,樹的特點就是查詢資料快按時資料增刪改比較慢。 2、資料庫的表拆分,分為水平拆分,垂直拆分,水平垂直拆分(自定義的)。

Oracle資料庫常用總結持續更新

Oracle是甲骨文(Oracle)公司的一款關係型資料庫管理系統(Relational Database Management System:RDBMS),在關係型資料庫領域,是最常用的資料庫之一,其他常用關係型資料庫還有:開源的MySQL,IBM的DB2

貝葉斯網路機器學習系列,持續更新~

在說貝葉斯規則(Bayes rule)和將貝葉斯規則用於圖模型之前,先讓大家瞭解下機器學習的四個正規化(paradigms),也可以理解為四個流派; 連線主義(connectionist):用現在比較流行的說法就是神經網路,現在用到的工具有Tensorflow

學習筆記——多執行緒持續更新

1、程序與執行緒的區別:程序是所有執行緒的集合,每一個執行緒是程序中的執行路徑。      根據我的理解,其實程序就可以看成是公共廁所,執行緒看做是廁所裡的隔斷間,一個廁所可以有很多個隔斷間,也可以有一個隔斷間。當人們上廁所的時候,如果廁所只有一個隔斷間上廁所的只有一個人,

navicat mysql查資料庫中表名、表數量,欄位名、欄位數量持續更新

1.查資料庫中表數量 (紅色標記的是常用到的重要的表結構資訊表) mysql> use information_schema;Database changedmysql> show tables;+-------------------------------

intellij idea工具學習持續更新

一、專案匯入和資料庫連線     1、匯入eclipse專案     2、匯入maven專案     3、匯入idea專案     4、從版本庫檢出專案     5、連線資料庫 二、工程結構和配置     1、建立和配置project     2、建立和配置module   

正則表示式學習記錄持續更新

特殊字元含義: 字元 含義 字元 含義 * 匹配前面的子表示式零次或多次 + 匹配一次或多次 $ 匹配輸入字串的結尾位置,設定RegExg物件的

【機器學習】演算法面試知識點整理持續更新~

1、監督學習(SupervisedLearning):有類別標籤的學習,基於訓練樣本的輸入、輸出訓練得到最優模型,再使用該模型預測新輸入的輸出;代表演算法:決策樹、樸素貝葉斯、邏輯迴歸、KNN、SVM、

PHP連線SQLite3資料庫持續更新

安裝 基本PHP5.3之後就不用特地安裝SQLite3動態連線庫了,如果實在不行,可以修改php.ini裡sqlite3的相關部分,把前面的註釋去掉,然後重啟伺服器即可。 PHP連線SQLite3 /* * connect to sqlite database */