orcle學習之路第三天

創建和操作表【完成】2h
1.sql
select * from zybrxx
Go go相當於orcle中的分號
2.Alter table:alter table zybq add test2 char(20)
添加多列:alter table zybq add (test1 char(1),test2 char(2))
把某一列的值允許爲null:alter table zybq modify(test2 char(20) null)
刪除;列:alter table zybq drop column test2
刪除多列:alter table zybq drop(test1,tets2)
alter table zybq modify (test2 char(1) )
alter table zybq add (test1 varchar2(10), test2 varchar(1));
alter table zybq add (test4 varchar2(10), test5 number,test6 varchar2(22));
select * from zybq
alter table zybq drop column test2
alter table zybq drop(test4,test5,test6)
3.Drop table:drop table test2
創建視圖和索引:【完成】2h
視圖:create view test2 as select * from ksmc
select * from test2
選擇指定列:create view test4(no,mc) as (select * from ksmc)
select * from test4錯誤
Create view test4(no,mc) as (select no,mc) from ksmc(正確)
4.對視圖進行操作(更新數據):update test2 set xh=xh+1
5.刪除視圖:drop view test2
索引
6.創建索引:create index myindex on ksmc(no)
複合索引:create index myindex on ksmc(no,id)
排序:create index myindex on ksmc (id desc)
7.刪除索引:Drop index myindex
事務處理控制【完成】2h
8.SET TRANSACTION
update zybq set test2=”
commit
9.SET TRANSACTION
update zybq set test2=”
rollback
10.數據庫安全【完成】2h
創建用戶:CREATE USER zxh IDENTIFIED BY password;
修改用戶密碼:ALTER USER zxh IDENTIFIED BY newpassword
11.創建角色:grant role to zxh with admin option
12.刪除角色:revoke role from zxh
其中角色有三種:
Connect:Connect 角色允許用戶從表中插入 更新 刪除屬於其它用戶的記錄 在取得了適當
的許可權限以後 用戶也可以創建表 視圖 序列 簇和同義詞
Resource:該角色允許用戶對 ORACLE 數據庫進行更多的訪問 除了可以賦予 Connect 角色的權限以外 它還有創建過程 觸發機制和索引的權限
Dba:DBA 角色包括了所有的權限 賦予了該角色的用戶可以在數據庫中做他們想做的任何

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章