主頁 > 資料庫 > oracle基礎語法

oracle基礎語法

2020-09-14 22:21:33 資料庫

ORACLE支持五種型別的完整性約束
NOT NULL (非空)--防止NULL值進入指定的列,在單列基礎上定義,默認情況下,ORACLE允許在任何列中有NULL值.
CHECK (檢查)--檢查在約束中指定的條件是否得到了滿足.
UNIQUE (唯一)--保證在指定的列中沒有重復值.在該表中每一個值或者每一組值都將是唯一的.
PRIMARY KEY (主鍵)--用來唯一的標識出表的每一行,并且防止出現NULL值,一個表只能有一個主鍵約束.
POREIGN KEY (外部鍵)--通過使用公共列在表之間建立一種父子(parent-child)關系,在表上定義的外部鍵可以指向主鍵或者其他表的唯一鍵.ORACLE支持五種型別的完整性約束


1--設定每行顯示多少字符 set linesize 300;
2 設定每頁顯示多少條記錄 set pagesize 30;
3 用戶名的切換: 如 conn system/tiger
Conn sys/change_on_install as sysdba(注意超級用戶 在后面加as sysdba)
4 在超級用戶下查找普通用戶的表是查不到的 必須這樣查找 如 select * from scott.emp(普通用戶下的emp表)
5 查看當前是那個用戶身份登錄: show user;
6 查看有多少張表: select * from tab;(注意不同用戶下的表是不同的)
7查看表的結構: desc emp(emp為表名)
8 取出重復的列(DISTINCT): 如 SELECT DISTINCT JOB EMP(去掉job的重復的值)
9字串的鏈接操作用: ||
10 查詢有獎金的員工: select* from emp where comm is not null;
11 查詢沒有獎金的員工資訊: select * from emp where comm is null;
12 兩個條件以上就得用and 如查詢工資大雨1500和有獎金的員工 select * from emp where sal>1500 and comm is not null;
13 表示兩個條件有一個滿足就可就用:or 如查詢工資大于1500或者沒有獎金的員工資訊
Select * from emp where sal>1500 or comm is not null;
14取反可以用not 如 查詢員工工資不大于1500和有獎金的員工資訊 如:
Select * from emp where not (sal>1500 or comm is not null);
15 在什么什么之間用between----and----如查詢工資在1500和3000之間的員工資訊:
Select * from emp where sal between 1500 and 3000;
16 查詢員工編號是2323, 4555, 2222的員工具體資訊: 如
Select * from emp where empno in(2323,4555,2222);
17.l模糊查詢 like 一般結合"%"和"_"使用其中%:表示可以匹配任意長度的內容,"_"表示匹配一個長度放入內容 如: 查詢員工姓名中第二哥字母是M的員工資訊:
Select * from emp where ename LIKE '_M%';
又如姓名中包含M的員工 Select * from emp where ename LIKE '%M%';
18oracle中不等于有兩種表示方式"<>"和"!="
19 排序用order by {asc desc}其中asc 是升序排列 如果不寫就默認按升序排列desc是按降序排列 排序陳述句放在sal陳述句的最后如: 按員工工資進行排序
Select * from emp order by sal asc(升序)
Selecct * from emp order by sal desc(降序)
Select * from emp where deptno='10' order by sal desc,hiredate asc;(查詢部門10的員工工資的升序排列如果工資相等就按員工的入職時間排序)
20.group by 用于對查詢的結果進行分組統計: 顯示每個部門的平均工資和最高工資 如:
Select avg(sal),max(sal) from emp group by deptno;

Having 子句用于限制分組顯示結果: 顯示平均工資大于2000的的部門號和他的平均工資?
如:select avg(sal), deptno from emp group by deptno having avg(sal)>2000;
2. 單行函式:
1 小寫變大寫: upper 如 select * from emp where ename=upper('smith');
講一個字串變為小寫字母表示 如: select lower('HELLO WORLD') FROM DUAL;
將單詞的首字母變大寫 用 INITCAP 如: SELECT INITCAP('HELLO WORLD') FROM DUAL;
2.字串的操作
Substr()截取字串 length()字串的長度 replace()替換字串
3數值函式
四舍五入: round();
截斷小數位:trunc();

一.入門部分
1. 創建表空間
create tablespace schooltbs datafile ‘D:\oracle\datasource\schooltbs.dbf’ size 10M autoextend on;
2. 洗掉表空間
drop tablespace schooltbs[including contents and datafiles];
3. 查詢表空間基本資訊
select *||tablespace_name from DBA_TABLESPACES;
4. 創建用戶
create user lihua
identified by lihua
default tablespace schooltbs
temporary tablespace temp;
5. 更改用戶
alter user lihua
identified by 123
default tablespace users;
6. 鎖定用戶
alter user lihua account lock|unlock;
7. 洗掉用戶
drop user lihua cascade;--洗掉用戶模式
8. oracle資料庫中的角色
connect,dba,select_catalog_role,delete_catalog_role,execute_catalog_role,exp_full_database,imp_full_database,resource
9. 授予連接服務器的角色
grant connect to lihua;
10.授予使用表空間的角色
grant resource to lihua with grant option;--該用戶也有授權的權限
11.授予操作表的權限
grant select,insert on user_tbl to scott;--當前用戶
grant delete,update on lihua.user_tbl to scott;--系統管理員
12.修改表的結構(alter)
Alter table 表名 add(列的名稱,列的型別);
二.SQL查詢和SQL函式
1.SQl支持的命令:
資料定義語言(DDL):create,alter,drop
資料操縱語言(DML):insert,delete,update,select
資料控制語言(DCL):grant,revoke
事務控制語言(TCL):commit,savepoint,rollback
2.Oracle資料型別
字符,數值,日期,RAW,LOB
字符型
char:1-2000位元組的定長字符
varchar2:1-4000位元組的變長字符
long:2GB的變長字符
注意:一個表中最多可有一列為long型
Long列不能定義唯一約束或主鍵約束
long列上不能創建索引
程序或存盤程序不能接受long型別的引數,

數值型
number:最高精度38位
日期時間型
date:精確到ss
timestamp:秒值精確到小數點后6位
函式
sysdate,systimestamp回傳系統當前日期,時間和時區,
更改時間的顯示
alter session set nls_date_language=’american’;
alter session set nls_date_format=’yyyy-mm-dd’;
Oracle中的偽列
像一個表列,但沒有存盤在表中
偽列可以查詢,但不能插入、更新和修改它們的值
常用的偽列:rowid和rownum
rowid:表中行的存盤地址,可唯一標示資料庫中的某一行,可以使用該列快速定位表中的行,
rownum:查詢回傳結果集中的行的序號,可以使用它來限制查詢回傳的行數,
3.資料定義語言
用于操作表的命令
create table
alter table
truncate table
drop table
修改表的命令
alter table stu_table rename to stu_tbl;--修改表名
alter table stu_tbl rename column stu_sex to sex;--修改列名
alter table stu_tbl add (stu_age number);--添加新列
alter table stu_tbl drop(sex);--洗掉列
alter table stu_tbl modify(stu_sex varchar2(2));--更改列的資料型別
alter table stu_tbl add constraint pk_stu_tbl primary key(id);--添加約束
4.資料操縱語言
select,update,delete,insert
利用現有的表創建表
create table stu_tbl_log as select id,stu_name,stu_age from stu_tbl;--
選擇無重復的行
select distinct stu_name from stu_tbl;--
插入來自其他表中的記錄
insert into stu_tbl_log select id,stu_name,stu_age from stu_tbl;
5.資料控制語言
grant,revoke
6.事務控制語言
commit,savepoint,rollback
7.SQL運算子
算術運算子:L+-*/
比較運算子:L=,!=,<>,>,<,>=,<=,between-and,in,like,is null等
邏輯運算子:Land,or,not
集合運算子:Lunion,union all,intersect,minus
連接運算子:L||
示例中stu_tbl_log中的資料如下:
ID STU_NAME STU_AGE
---------- -------------------- ----------
1000 李華 20
1001 accp 20
1003 nimda 3
stu_tbl中的資料如下:
ID STU_NAME ST STU_AGE
---------- -------------------- -- ----------
1000 李華 男 20
1001 accp 男 20
1002 admin 男 30
示例:
select (3+2)/2 from dual;--算術運算子,結果:2.5
select * from stu_tbl where stu_age>=20;--比較運算子
select * from stu_tbl where stu_name like '%a%';--比較運算子:like
select * from stu_tbl where stu_name like 'a___';--比較運算子:like
select * from stu_tbl where stu_age in(20,30);--比較運算子:in
select * from stu_tbl where stu_age between 20 and 30;--比較運算子:between
select stu_name from stu_tbl union all
select stu_name from stu_tbl_log;--集合運算子:union all,測驗結果具體如下:
STU_NAME
-----------
李華
accp
admin
李華
accp
nimda

已選擇6行,
select stu_name from stu_tbl union
select stu_name from stu_tbl_log;--集合運算子:union,測驗結果具體如下:
STU_NAME
---------
accp
admin
nimda
李華
select stu_name from stu_tbl intersect
select stu_name from stu_tbl_log;--集合運算子:intersect,測驗結具體如下:
STU_NAME
----------
accp
李華
select stu_name from stu_tbl minus
select stu_name from stu_tbl_log;--集合運算子:minus,測驗結果如下:
STU_NAME
----------
Admin
從中可以看出:
minus是獲取第一張表獨有的資料
intersect是獲取兩張表中都有的資料
union是整合兩張表的資料,都有的只顯示一次
union all是純粹的兩張表資料整合
select id,stu_name||' '||stu_sex as name_sex,stu_age
from stu_tbl;--連接運算子||,測驗結果具體如下:
ID NAME_SEX STU_AGE
---------- ----------------------- ----------
1000 李華 男 20
1001 accp 男 20
1002 admin 男 30

8.SQL函式
單行函式:從表中查詢的每一行只回傳一個值,可出現在select子句,where子句中
日期函式
數字函式
字符函式
轉換函式:ToChar(),ToDate(),ToNumber()
其他函式:
Nvl(exp1,exp2):運算式一為null時,回傳運算式二
Nvl2(exp1,exp2,exp3):運算式一為null時回傳運算式三,否則回傳運算式二
Nullif(exp1,exp2):兩運算式相等時,回傳null,否則回傳運算式一
分組函式:基于一組行來回傳
Avg,Min,Max,Sum,Count
Group by,having
分析函式
Row_number,rank,dense_rank
示例:
select u.user_name,sum(oi.order_num*oi.order_price) as total,row_number() over (order by sum(oi.order_num*oi.order_price) desc) as sort from order_item_tbl
oi,user_tbl u,order_tbl o where oi.order_id = o.id and o.user_id = u.id group by u.user_name;

三.鎖和資料庫物件
1.鎖:資料庫用來控制共享資源并發訪問的機制,
鎖的型別:行級鎖,表級鎖
行級鎖:對正在被修改的行進行鎖定,行級鎖也被稱之為排他鎖,
在使用下列陳述句時,Oracle會自動應用行級鎖:
insert,update,delete,select…… for update
select……for update允許用戶一次鎖定多條記錄進行更新,
使用commit or rollback釋放鎖,
表級鎖:
lock table user_tbl in mode mode;
表級鎖型別:
行共享 row share
行排他 row exclusive
共享 share
共享行排他 share row exclusive
排他 exclusive
死鎖:兩個或兩個以上的事務相互等待對方釋放資源,從而形成死鎖
2.資料庫物件
oracle資料庫物件又稱模式物件
資料庫物件是邏輯結構的集合,最基本的資料庫物件是表
資料庫物件:
表,序列,視圖,索引

序列
用于生成唯一,連續序號的物件,
創建語法:
create sequence user_id_seq
start with 1000
increment by 1
maxvalue 2000
minvalue 1000
nocycle
cache 1000;--指定記憶體中預先分配的序號
訪問序列:
select user_id_seq.currval from dual;
select user_id-seq.nextval from dual;
更改洗掉序列:
alter sequence user_id_seq maxvalue 10000;--不能修改其start with 值
drop sequence user_id_seq;
在Hibernate中訪問序列:

user_id_seq

視圖
以經過定制的方式顯示來自一個或多個表的資料
創建視圖:
create or replace view
user_tbl_view (vid,vname,vage)
as select id,user_name,age from user_tbl
[with check option]|[with read only];
創建帶有錯誤的視圖:
create force view user_tbl_force_view as
select * from user_table;--此時user_table可以不存在
創建外聯接視圖:
create view user_stu_view as
select u.id,u.user_name,u.password,s.ddress
from user_tbl u,stu_tbl s
where u.s_id(+)=s.id;--哪一方帶有(+),哪一方就是次要的
洗掉視圖:
drop user_stu_view;

索引
用于提高SQL陳述句執行的性能
索引型別:
唯一索引,位圖索引,組合索引,基于函式的索引,反向鍵索引
創建標準索引:
create index user_id_index on user_tbl(id) tablespace schooltbs;
重建索引:
alter index user_id_index rebuild;
洗掉索引:
drop index user_id_index;
創建唯一索引:
create unique index user_id_index on user_tbl(id);
創建組合索引:
create index name_pass_index on user_tbl(user_name,password);
創建反向鍵索引:
create index user_id_index on user_tbl(id) reverse;

四.使用PL/SQL
可用于創建存盤程序,觸發器,程式包,給SQL陳述句的執行添加程式邏輯,
支持SQL,在PL/SQL中可以使用:
資料操縱命令
事務控制命令
游標控制
SQL函式和SQL運算子
支持面向物件編程(OOP)
可移植性
更佳的性能,PL/SQL經過編譯執行

分為三個部分:宣告部分,可執行部分和例外處理部分
[declare
declarations]
begin
executable statements
[exception
handlers]
end;
打開輸出
set serverout on;

--根據輸入編號獲取某學員的成績--if
declare
score user_tbl.score%type;
begin
select score into score from user_tbl where id='&id';
if score>90 then
dbms_output.put_line('優秀');
elsif score>80 then
dbms_output.put_line('良好');
elsif score>60 then
dbms_output.put_line('及格');
else
dbms_output.put_line('差');
end if;
end;

--根據學員姓名獲取某學員的成績--if
declare
score user_tbl.score%type;
begin
select score into score from user_tbl where user_name='&name';
if score>90 then
dbms_output.put_line('優秀');
elsif score>80 then
dbms_output.put_line('良好');
elsif score>60 then
dbms_output.put_line('及格');
else
dbms_output.put_line('差');
end if;
end;

--case的使用
declare
grade user_tbl.grade%type;
begin
select grade into grade from user_tbl where id='&id';
case 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;

--基本回圈
declare
i number(4):=1;
begin
loop
dbms_output.put_line('loop size:'||i);
i:=i+1;
exit when i>10;
end loop;
end;


--while回圈
declare
i number(4):=1;
begin
while i<=10 loop
dbms_output.put_line('while loop size='||i);
i:=i+1;
end loop;
end;

--for回圈
declare
i number(4):=1;
begin
for i in 1..10 loop
dbms_output.put_line('for loop Size:'||i);
end loop;
end;

declare
i number(2):=1;
j number(2):=1;
begin
for i in reverse 1..9 loop
for j in 1..i loop
dbms_output.put(j||'x'||i||'='||j*i||' ');
end loop;
dbms_output.put_line('');
end loop;
end;

--動態SQL
declare
userId number(2);
sql_str varchar2(100);
userName user_tbl.user_name%type;
begin
execute immediate 'create table testExe(id number,test_name varchar2(20))';
userId:='&userId';
sql_str:='select user_name from user_tbl where id=:id';
execute immediate sql_str into userName using userId;
dbms_output.put_line(userName);
end;
(or
declare
id_param number:='&id_param';
sql_str varchar2(100);
name_param stu_tbl.stu_name%type;
begin
sql_str:='select stu_name from stu_tbl where id=:p';
execute immediate sql_str into name_param using id_param;
dbms_output.put_line(name_param);
end;
/
)

--例外處理
declare
grade number(4);
begin
grade:='&grade';
case grade
when 1 then dbms_output.put_line('好的');
--else dbms_output.put_line('不好');
end case;
exception
when case_not_found then
dbms_output.put_line('輸入型別不匹配!');
end;

--系統例外
declare
rowD user_tbl%rowtype;
begin
select * into rowD from user_tbl;
dbms_output.put_line(rowD.id||''||rowD.user_name||' '||rowD.password);
exception
when too_many_rows then
dbms_output.put_line('不能將多行賦予一個屬性!');
end;
or
declare
rowD user_tbl%rowtype;
begin
select * into rowD from user_tbl where id=5;
dbms_output.put_line(rowD.id||' '||rowD.user_name||' '||rowD.password);
exception
when too_many_rows then
dbms_output.put_line('不能將多行賦予一個屬性!');
when no_data_found then
dbms_output.put_line('沒有您要查找的資料!');
end;

--自定義錯誤
declare
invalidError exception;
category varchar2(20);
begin
category:='&category';
if category not in('附件','頂盤','備件') then
raise invalidError;
else
dbms_output.put_line('您輸入的類別是:'||category);
end if;
exception
when invalidError then
dbms_output.put_line('無法識別的類別!');
end;

--引發應用程式例外
declare
app_exception exception;
grade user_tbl.grade%type;
begin
select grade into grade from user_tbl where id=&id;
if grade='A' then
raise app_exception;
else
dbms_output.put_line('查詢的等級為:'||grade);
end if;
exception
when app_exception then
raise_application_error(-20001,'未知的等級!');
end;

五、游標管理
游標型別:隱式游標,顯式游標,REF游標
REF游標用于處理運行時才能確定的動態SQL查詢的結果

==========隱式游標==========
在PL/SQL中使用DML陳述句時自動創建隱式游標
隱式游標自動宣告、打開和關閉,其名為SQL
隱式游標的屬性:
%found SQL陳述句影響實質后回傳true
%notfound SQL陳述句沒有影響實質后回傳true
%rowcount SQL陳述句影響的行數
%isopen 游標是否打開,始終為false
示例:
begin
update user_tbl set score=score+5;
if SQL%found then
dbms_output.put_line('資料被更改: '||SQL%rowcount);
elsif sql%notfound then
dbms_output.put_line('沒有找到資料!');
end if;
if SQL%isopen then
dbms_output.put_line('Open');
else
dbms_output.put_line('Close');
end if;
end;

==========顯式游標==========
在PL/SQL的宣告部分定義查詢,該查詢可以回傳多行
J 宣告游標
J 打開游標
J 從游標中取回資料
J 關閉游標
宣告游標完成兩個任務:
給游標命名
將一個查詢與游標關聯
cursor cursor_name is select statement;
打開游標:
open cursor_name;
取資料:
fetch cursor_name into record_list;
關閉游標:
close cursor_name;
顯式游標的屬性:
%found 執行最后一條fetch陳述句成功回傳行時為true
%notfound 執行最后一條fetch陳述句未能回傳行時為true
%rowcount 回傳到目前為止游標提取的行數
%isopen 游標是否打開

示例:
declare
users user_tbl%rowtype;
cursor boys_cur is select * from user_tbl where sex='h';
begin
open boys_cur;
loop
fetch boys_cur into users;
exit when boys_cur%notfound;
dbms_output.put_line(users.user_name||' '||users.password);
dbms_output.put_line(boys_cur%rowcount);
end loop;
close boys_cur;
end;

帶參的顯式游標
declare
users user_tbl%rowtype;
cursor boys_cur(sexParam varchar2)
is select * from user_tbl where sex=sexParam;
begin
open boys_cur('&sex');
loop
fetch boys_cur into users;
exit when boys_cur%notfound;
dbms_output.put_line(users.user_name||' '||users.password);
dbms_output.put_line(boys_cur%rowcount);
end loop;
close boys_cur;
end;

使用顯式游標更新行
declare
cursor user_update_cur is select sex from user_tbl for update;
usersex user_tbl.sex%type;
begin
open user_update_cur;
loop
fetch user_update_cur into usersex;
exit when user_update_cur%notfound;
dbms_output.put_line(usersex);
if usersex = 'M' then
update user_tbl set score=score-5 where current of user_update_cur;
else
update user_tbl set score=score+5 where current of user_update_cur;
end if;
end loop;
close user_update_cur;
commit;
end;

回圈游標
declare
cursor user_cur is select * from user_tbl;
begin
for username in user_cur loop
dbms_output.put_line(username.user_name||' '||username.sex);
end loop;
end;

==========REF游標==========
REF游標和游標變數用于處理運行時動態執行的SQL查詢
創建游標變數的步驟:
J 宣告REF游標型別
J 宣告REF游標型別的變數
宣告型別的語法
Type ref_cursor_name is ref cursor [return return_type];
打開游標變數的語法
Open cursor_name for select_statement;
----宣告強型別的游標
declare
type ref_cur is ref cursor return user_tbl%rowtype;
users_cur ref_cur;
----宣告弱型別的游標
declare
type ref_cur is ref cursor;
users_cur ref_cur;
示例
----強型別
declare
type ref_cur is ref cursor return user_tbl%rowtype;
users_cur ref_cur;
users user_tbl%rowtype;
begin
open users_cur for select * from user_tbl where user_name='ny2t92';
loop
fetch users_cur into users;
exit when users_cur%notfound;
dbms_output.put_line(users.user_Name);
end loop;
close users_cur;
end;
----弱型別
declare
type ref_cur is ref cursor;
my_cur ref_cur;
users user_tbl%rowtype;
stus stu_tbl%rowtype;
begin
open my_cur for select * from user_tbl;
loop
fetch my_cur into users;
exit when my_cur%notfound;
dbms_output.put_line(users.user_Name);
end loop;
close my_cur;
open my_cur for select * from user_tbl where user_name='ny2t92';
loop
fetch my_cur into users;
exit when my_cur%notfound;
dbms_output.put_line(users.user_Name);
end loop;
close my_cur;
open my_cur for select * from stu_tbl;
loop
fetch my_cur into stus;
exit when my_cur%notfound;
dbms_output.put_line(stus.stu_Name);
end loop;
close my_cur;
end;
----動態SQL游標
declare
type ref_cur is ref cursor;
my_cur ref_cur;
users user_tbl%rowtype;
username varchar2(20);
sqlstmt varchar2(200);
begin
username:='&username';
sqlstmt := 'select * from user_tbl where user_name= :name';
open my_cur for sqlstmt using username;
loop
fetch my_cur into users;
exit when my_cur%notfound;
dbms_output.put_line(users.user_Name);
end loop;
close my_cur;
end;


六.子程式
子程式分為:存盤程序和函式,它是命名的PL/SQL塊,編譯并存盤在資料庫中,
子程式的各個部分:宣告部分,可執行部分,例外處理部分,
程序----執行某些操作
函式----執行操作并回傳值

==========存盤程序==========
創建程序的語法:
create or replace procedure
proce_name (parameter_list)
is|as
local variable declaration
begin
executable statements
exception
exception_handlers
end proce_name;

程序引數的三種模式:
In----用于接收呼叫的值,默認的引數模式
Out----用于向呼叫程式回傳值
In out----用于接收呼叫程式的值,并向呼叫程式回傳更新的值
執行程序的語法:
Execute proce_name(parameter_list);

Declare
Variable var_list;
Begin
Proce_name(var_list);
End;
將程序執行的權限授予其他用戶:
Grant execute on proce_name to scott;
Grant execute on proce_name to public;
洗掉存盤程序:
Drop procedure proce_name;

==========函式==========
創建函式的語法:
Create or replace function
Fun_name (parameter_list)
Return datatype is|as
Local declarations
Begin
Executable statements;
Return result;
Exception
Exce_handlers;
End;
函式只能接收in引數,不能接受out或in out引數,形參不能是PL/SQL型別
函式的回傳型別也必須是資料庫型別
訪問函式的方式:
J 使用PL/SQL塊
J 使用SQL陳述句
Select fun_name(parameter_list) from dual;

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/39212.html

標籤:Oracle

上一篇:[20190920]完善vim呼叫sqlplus腳本.txt

下一篇:lob 按ROWID磁區并行匯出

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • GPU虛擬機創建時間深度優化

    **?桔妹導讀:**GPU虛擬機實體創建速度慢是公有云面臨的普遍問題,由于通常情況下創建虛擬機屬于低頻操作而未引起業界的重視,實際生產中還是存在對GPU實體創建時間有苛刻要求的業務場景。本文將介紹滴滴云在解決該問題時的思路、方法、并展示最終的優化成果。 從公有云服務商那里購買過虛擬主機的資深用戶,一 ......

    uj5u.com 2020-09-10 06:09:13 more
  • 可編程網卡芯片在滴滴云網路的應用實踐

    **?桔妹導讀:**隨著云規模不斷擴大以及業務層面對延遲、帶寬的要求越來越高,采用DPDK 加速網路報文處理的方式在橫向縱向擴展都出現了局限性。可編程芯片成為業界熱點。本文主要講述了可編程網卡芯片在滴滴云網路中的應用實踐,遇到的問題、帶來的收益以及開源社區貢獻。 #1. 資料中心面臨的問題 隨著滴滴 ......

    uj5u.com 2020-09-10 06:10:21 more
  • 滴滴資料通道服務演進之路

    **?桔妹導讀:**滴滴資料通道引擎承載著全公司的資料同步,為下游實時和離線場景提供了必不可少的源資料。隨著任務量的不斷增加,資料通道的整體架構也隨之發生改變。本文介紹了滴滴資料通道的發展歷程,遇到的問題以及今后的規劃。 #1. 背景 資料,對于任何一家互聯網公司來說都是非常重要的資產,公司的大資料 ......

    uj5u.com 2020-09-10 06:11:05 more
  • 滴滴AI Labs斬獲國際機器翻譯大賽中譯英方向世界第三

    **桔妹導讀:**深耕人工智能領域,致力于探索AI讓出行更美好的滴滴AI Labs再次斬獲國際大獎,這次獲獎的專案是什么呢?一起來看看詳細報道吧! 近日,由國際計算語言學協會ACL(The Association for Computational Linguistics)舉辦的世界最具影響力的機器 ......

    uj5u.com 2020-09-10 06:11:29 more
  • MPP (Massively Parallel Processing)大規模并行處理

    1、什么是mpp? MPP (Massively Parallel Processing),即大規模并行處理,在資料庫非共享集群中,每個節點都有獨立的磁盤存盤系統和記憶體系統,業務資料根據資料庫模型和應用特點劃分到各個節點上,每臺資料節點通過專用網路或者商業通用網路互相連接,彼此協同計算,作為整體提供 ......

    uj5u.com 2020-09-10 06:11:41 more
  • 滴滴資料倉庫指標體系建設實踐

    **桔妹導讀:**指標體系是什么?如何使用OSM模型和AARRR模型搭建指標體系?如何統一流程、規范化、工具化管理指標體系?本文會對建設的方法論結合滴滴資料指標體系建設實踐進行解答分析。 #1. 什么是指標體系 ##1.1 指標體系定義 指標體系是將零散單點的具有相互聯系的指標,系統化的組織起來,通 ......

    uj5u.com 2020-09-10 06:12:52 more
  • 單表千萬行資料庫 LIKE 搜索優化手記

    我們經常在資料庫中使用 LIKE 運算子來完成對資料的模糊搜索,LIKE 運算子用于在 WHERE 子句中搜索列中的指定模式。 如果需要查找客戶表中所有姓氏是“張”的資料,可以使用下面的 SQL 陳述句: SELECT * FROM Customer WHERE Name LIKE '張%' 如果需要 ......

    uj5u.com 2020-09-10 06:13:25 more
  • 滴滴Ceph分布式存盤系統優化之鎖優化

    **桔妹導讀:**Ceph是國際知名的開源分布式存盤系統,在工業界和學術界都有著重要的影響。Ceph的架構和演算法設計發表在國際系統領域頂級會議OSDI、SOSP、SC等上。Ceph社區得到Red Hat、SUSE、Intel等大公司的大力支持。Ceph是國際云計算領域應用最廣泛的開源分布式存盤系統, ......

    uj5u.com 2020-09-10 06:14:51 more
  • es~通過ElasticsearchTemplate進行聚合~嵌套聚合

    之前寫過《es~通過ElasticsearchTemplate進行聚合操作》的文章,這一次主要寫一個嵌套的聚合,例如先對sex集合,再對desc聚合,最后再對age求和,共三層嵌套。 Aggregations的部分特性類似于SQL語言中的group by,avg,sum等函式,Aggregation ......

    uj5u.com 2020-09-10 06:14:59 more
  • 爬蟲日志監控 -- Elastc Stack(ELK)部署

    傻瓜式部署,只需替換IP與用戶 導讀: 現ELK四大組件分別為:Elasticsearch(核心)、logstash(處理)、filebeat(采集)、kibana(可視化) 下載均在https://www.elastic.co/cn/downloads/下tar包,各組件版本最好一致,配合fdm會 ......

    uj5u.com 2020-09-10 06:15:05 more
最新发布
  • day02-2-商鋪查詢快取

    功能02-商鋪查詢快取 3.商鋪詳情快取查詢 3.1什么是快取? 快取就是資料交換的緩沖區(稱作Cache),是存盤資料的臨時地方,一般讀寫性能較高。 快取的作用: 降低后端負載 提高讀寫效率,降低回應時間 快取的成本: 資料一致性成本 代碼維護成本 運維成本 3.2需求說明 如下,當我們點擊商店詳 ......

    uj5u.com 2023-04-20 08:33:24 more
  • MySQL中binlog備份腳本分享

    關于MySQL的二進制日志(binlog),我們都知道二進制日志(binlog)非常重要,尤其當你需要point to point災難恢復的時侯,所以我們要對其進行備份。關于二進制日志(binlog)的備份,可以基于flush logs方式先切換binlog,然后拷貝&壓縮到到遠程服務器或本地服務器 ......

    uj5u.com 2023-04-20 08:28:06 more
  • day02-短信登錄

    功能實作02 2.功能01-短信登錄 2.1基于Session實作登錄 2.1.1思路分析 2.1.2代碼實作 2.1.2.1發送短信驗證碼 發送短信驗證碼: 發送驗證碼的介面為:http://127.0.0.1:8080/api/user/code?phone=xxxxx<手機號> 請求方式:PO ......

    uj5u.com 2023-04-20 08:27:27 more
  • 快取與資料庫雙寫一致性幾種策略分析

    本文將對幾種快取與資料庫保證資料一致性的使用方式進行分析。為保證高并發性能,以下分析場景不考慮執行的原子性及加鎖等強一致性要求的場景,僅追求最終一致性。 ......

    uj5u.com 2023-04-20 08:26:48 more
  • sql陳述句優化

    問題查找及措施 問題查找 需要找到具體的代碼,對其進行一對一優化,而非一直把關注點放在服務器和sql平臺 降低簡化每個事務中處理的問題,盡量不要讓一個事務拖太長的時間 例如檔案上傳時,應將檔案上傳這一步放在事務外面 微軟建議 4.啟動sql定時執行計劃 怎么啟動sqlserver代理服務-百度經驗 ......

    uj5u.com 2023-04-20 08:26:35 more
  • 云時代,MySQL到ClickHouse資料同步產品對比推薦

    ClickHouse 在執行分析查詢時的速度優勢很好的彌補了MySQL的不足,但是對于很多開發者和DBA來說,如何將MySQL穩定、高效、簡單的同步到 ClickHouse 卻很困難。本文對比了 NineData、MaterializeMySQL(ClickHouse自帶)、Bifrost 三款產品... ......

    uj5u.com 2023-04-20 08:26:29 more
  • sql陳述句優化

    問題查找及措施 問題查找 需要找到具體的代碼,對其進行一對一優化,而非一直把關注點放在服務器和sql平臺 降低簡化每個事務中處理的問題,盡量不要讓一個事務拖太長的時間 例如檔案上傳時,應將檔案上傳這一步放在事務外面 微軟建議 4.啟動sql定時執行計劃 怎么啟動sqlserver代理服務-百度經驗 ......

    uj5u.com 2023-04-20 08:25:13 more
  • Redis 報”OutOfDirectMemoryError“(堆外記憶體溢位)

    Redis 報錯“OutOfDirectMemoryError(堆外記憶體溢位) ”問題如下: 一、報錯資訊: 使用 Redis 的業務介面 ,產生 OutOfDirectMemoryError(堆外記憶體溢位),如圖: 格式化后的報錯資訊: { "timestamp": "2023-04-17 22: ......

    uj5u.com 2023-04-20 08:24:54 more
  • day02-2-商鋪查詢快取

    功能02-商鋪查詢快取 3.商鋪詳情快取查詢 3.1什么是快取? 快取就是資料交換的緩沖區(稱作Cache),是存盤資料的臨時地方,一般讀寫性能較高。 快取的作用: 降低后端負載 提高讀寫效率,降低回應時間 快取的成本: 資料一致性成本 代碼維護成本 運維成本 3.2需求說明 如下,當我們點擊商店詳 ......

    uj5u.com 2023-04-20 08:24:03 more
  • day02-短信登錄

    功能實作02 2.功能01-短信登錄 2.1基于Session實作登錄 2.1.1思路分析 2.1.2代碼實作 2.1.2.1發送短信驗證碼 發送短信驗證碼: 發送驗證碼的介面為:http://127.0.0.1:8080/api/user/code?phone=xxxxx<手機號> 請求方式:PO ......

    uj5u.com 2023-04-20 08:23:11 more