資料庫基礎二

2021-10-13 12:46:19 字數 2281 閱讀 5876

主要有create、select、insert、update、delete和drop

①資料定義(create、prop)

②資料操縱(select、insert、update、delete)

③資料控制(grant、reroke)

①create 建立新的表、檢視或者其他資料庫中的物件

create table [表名]

(column_name1 data_type

(size)

. column_name2 data_type

(size)

, column_name2 data_type

(size)

);

例:建立乙個名為persons的表,其中包含五列:personid、lastname、firstname、address、city

create table persons

(personid int,

lastname char(25

),firstname char(25

),address char(40

),city char(20

));

②alter alter 修改現存資料庫物件

③drop drop 刪除表、檢視或資料庫中的其他物件

drop table;刪除表

drop database;刪除資料庫

④select 查詢;從一張或多張表中檢索特定的資料
select colume_name,column_name1 from table_name;查詢table_name表中的列

select *

from table_name;查詢table_name表中的所有內容(*表示所有)

select name, country from websites;查詢websites表中的name,country

⑤insert 建立一條新的記錄
insert into:向表中插入資訊

;

⑥update 更新
update table_name

set column1=value1,column2=value2,

...;

where some_column=some_value;

例子:把「菜鳥教程」的alexa排名更新為5000,country改為usa

update websites

et alexa=

'5000'

,country=

'usa'

where name=

'菜鳥教程'

⑦delete 刪除表中的資訊
delete

from table_name

where some_colum=some_value;

delete

*from websites

where name=

'facebook' and country=

'usa'

⑧grant 賦權
grant

《許可權》

on 表名[

(列名)

] to 使用者 with grant option

例子:用授權命令grant給user1新增查詢的許可權

grant select on student to user1

with grant option

⑨revoke **許可權
revoke

《許可權》

on《資料物件》

from

《資料庫使用者名稱》

revoke select on student from user1

資料庫基礎 二

title 資料庫基礎 二 author 軟帝學院 summary 多表關聯,三階正規化 categories 表與表之間有引用的關係 將乙個表的資料拆分為多個表 降低冗餘,但是查詢效率會變低 設計資料庫的乙個標準 正規化等級越高,冗餘越低,一般的專案達到三階正規化就ok 傳統專案 一階正規化 表中...

oracle資料庫基礎二

1.查詢等待資源的會話的檢視 v session和v session wait 2.三中收集advisory statistics buffer cache advice,segment level statistics,timed statistics 3.檢視資料庫的時區 select dbti...

mysql資料庫基礎(二)

1.的用法 2.not 的用法 where end isnull andnot title hello dept id select dept id from department where name loans date between 2005 01 01 and 2005 12 31 1.b...