-“熟悉數據庫就是會增刪改查嗎?”
-“還應包括:多表關聯查詢轻庆、分組查詢癣猾、統(tǒng)計查詢、常用函數余爆、運維技巧纷宇。”
目前的測試工作中蛾方,基礎 sql語句的使用較頻繁像捶,粗略總結增刪改的應用。
一桩砰、功能點:同步數據源
功能點UI
二拓春、測試需求分析
梳理測試點
三、測試用例中使用到的sql語句
== 表 ==
【新建表】
create table t333(
id int not null default 0 primary key,
department varchar(40) not null default ' '
); --mysql建表
create table table1(
id varchar2(40) not null,
username varchar2(40) not null,
constraint database_table1 primary key (id)
); --oracle建表
【修改表名】
alter table test rename test1;
【拷貝表亚隅、備份表】
--Method 1:
create table t333_copy like t333;
insert into t333_copy select * from t333;
--Method 2:
create table t333_copy as select * from t333;
【插入多行表記錄】
insert into table1 values ('I1','Ada'),
('I2','Beta'),
('I3','Cate');
【修改表名】
rename table1 to table2;
【刪除表】
drop table t333;
== 字段 ==
【添加字段】
--添加字段phone
alter table t333 add phone varchar(60) not null; ```
【修改字段名】
--Method 1:
alter table t333 change column phone phone333 varchar(60) not null;
--Method 2:
alter table t333 rename column phone to phone333;
【修改字段類型硼莽、長度】
--Step 1:
alter table t333 modify column phone333 char(30) not null;
--Step 2:
alter語句運行完畢,在查詢界面煮纵,選中表t333使用快捷鍵 [ctrl+d ]懂鸵,顯示表結構
【修改字段數據】
update t333 set department='dpmtA' where id=3;
【刪除字段】
alter table t333 drop column phone333;