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

2021-06-22 14:21:39 字數 1365 閱讀 8863

/*建立表*/

create table t1

(id number(10),

name varchar(20),

password varchar(30)

);/*插入資料*/

insert into table1 values(1,'zhiguo','123123','軟體工程師','系統整合','普通員工');

/*查詢表*/

select * from table1 ;

/*增加字段*/

alter table t1 add(job varchar(10));

alter table t1 add(job1 varchar(10));

alter table t1 add(job2 varchar(10));

/*修改表已存列的資料型別與列名重新命名*/

--1.更新資料型別

alter table t1 modify(job varchar(50));

--2.列名重新命名

alter table t1 rename column job to gz;

/*插入字段值*/

insert into t1(job) values('軟體實施工程師');

/*刪除表裡的某列*/

alter table t1 drop column gz;

/*間接刪除表裡已存在的列

刪除表裡的列特別是刪除大表裡的列是特耗資源的 所以 在刪除乙個列時 可以先把要刪除的列打標記,標記成無用列 ,然後等系統不忙時在徹底刪除這個列

*/--標記無用字段

alter table t1 set unused column job1;

--刪除標記為無用欄位的字段

alter table t1 drop unused column;

/*當乙個表裡的資料不再需要時,可以適用truncate table 全部刪除表裡的資料,該語句為ddl語句 無法適用rollback 來回滾資料*/

/*如果只刪除資料,而保留資料結構 適用truncate  如果既要刪除資料,也要刪除表結構 適用drop*/

--truncate方法

truncate table t1;

--drop方法

drop table t1;

/*物件表的重新命名*/

rename t1 to table1;

/*清空閃回**站*/

purge recyclebin;

/*更新資料*/

update table1 set job1='實施工程師' where name='zhiguo';

/*刪除行*/

delete from table1 where job1='普通員工';

Oracle的基本語法 增刪改查

表的操作 建立表 create table 表名 列名 屬性 檢視表結構 desc 表名 表重新命名 rename 原表名 to 新錶名 刪除表 drop 表名 表的字段操作 增 alter table 表名 add 列名 列的屬性 單列操作 alter table 表名 add 列名1 列1的屬性...

Oracle 的增刪改查

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

mysql 基本增刪改查

mysql是關係型資料庫 關係型資料庫的特點 1,資料時以行和列的形式去儲存的 2,這一行系列的行和列稱為表 3,表中的每一行叫一條記錄 4,表中的每一列叫乙個字段 5,表和表之間的邏輯關聯叫關係 一,基本sql命令 sql命令的使用規則 1,每條命令必須以分號結尾 2,sql命令不區分字母大小寫 ...