Oracle的基本語法 增刪改查

2022-08-27 08:12:09 字數 1122 閱讀 1571

表的操作:

建立表:

create table 表名

列名 屬性;

檢視表結構:

desc 表名;

表重新命名:

rename 原表名 to 新錶名; 

刪除表:

drop 表名;

表的字段操作:

增: alter table 表名 add 列名  列的屬性; --單列操作

alter table 表名 add (列名1 列1的屬性,列名2 列2的屬性,...) --多列操作

刪: alter table 表名 drop column 列名;  --單列操作

alter table 表名 drop (列1,列2);  --多列操作(多列不需要加column)

改:   

alter table 表名 modify 列名 新屬性; --單列操作

alter table 表名 modify (列名1 列1的新屬性,列名2 列2的新屬性);--多列操作

資料的操作:

增:--單行操作

insert into 表名 values(所有列的資訊);  --資料型別必須與表結構裡字段的屬性一致

insert into 表名 values(部分資訊); --會按表的字段順序加入資訊,後面沒設定的為null(輸入資料必須小於或等於列數)

--多行操作

刪:delete from 表名  --刪除所有資料

delete 列名 from 表名 where 條件 --刪除符合條件的某些資料

刪除某一列資料(該列必須可以為null):

1.update 表名 set 列名=null;

2.delete from 表名 where 列名 is not null ;

改:update 表名 set 列名=資料 where 條件; --修改滿足條件的資料

update 表名 set 列名=資料; --將該列全部修改

檢視:

select * from 表名; --檢視表的全部資訊

select 列1,列2 from 表名; --檢視表的列1,列2資訊

Oracle 的增刪改查

新增 system.data.oracleclient 已過時 或者新增 oracle.dataaccess.dll 在oracle 安裝目錄中有。name oracle connectionstring data source orcl user id oracle password 123456...

sql增刪改查語法

1.使用insert插入單行資料 語法 insert into 表名 列名 values 列值 例 insert into strdents 姓名,性別,出生日期 values 斌 男 1993 6 15 注意 into可以省略 列名列值用逗號分開 列值用單引號因上 如果省略表名,將依次插入所有列 ...

基本 Oracle 增刪改查 自己總結的

建立表 create table t1 id number 10 name varchar 20 password varchar 30 插入資料 insert into table1 values 1,zhiguo 123123 軟體工程師 系統整合 普通員工 查詢表 select from ta...