Giáo trình Công nghệ Oracle - Bài 9: Quản lý Users - Nguyễn Việt Hưng

1. Create user Bob with a password of CRUSADER. Make sure that any objects and temporary segments created by Bob are not created in the system tablespace. Also, make sure that Bob can log in and create objects up to one megabyte in size in the tablespace USERS. Hint: Assign Bob the default tablespace of USERS and temporary tablespace TEMP. 2 Create a user Emi with a password of Mary. Make sure that any objects and sort segments created by Emi are not created in the system tablespace. 3 Display the information on Bob and Emi from the data dictionary. Hint: This can be obtained by querying DBA_USERS. 4 From the data dictionary, display the information on the amount of space that Bob can use in tablespaces. Hint: This can be obtained by querying DBA_TS_QUOTAS. 5. As user Bob, change his password to Sam. 6 As user SYSTEM, remove Bob’s quota on his default tablespace. 7 Remove the Emi account from the database. 8 Bob has forgotten his password. Assign him a password of OLINK and require that Bob change his password the next time he logs on.

pptx13 trang | Chia sẻ: huongthu9 | Lượt xem: 448 | Lượt tải: 0download
Bạn đang xem nội dung tài liệu Giáo trình Công nghệ Oracle - Bài 9: Quản lý Users - Nguyễn Việt Hưng, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
QUẢN LÝ USERSBiên soạn: Nguyễn Việt HưngBộ môn: Khoa Học Máy Tính - Khoa Công Nghệ Thông TinTrường Đại Học Giao Thông Vân TảiWebsite: https://sites.google.com/site/viethung92gtvt/oracle-dbaEmail : viethung92gtvt@gmail.com1. Mục đíchMục đíchSau khi hoàn thành bài học này, bạn sẽ có thể: Tạo ra database user mới.Thay đổi và hủy bỏ database user hiện có.Kiểm soát thông tin về user hiện có.Lấy thông tin về user.Database SchemaSchema ObjectsTablesTriggersConstraintsIndexesViewsSequencesStored program unitsSynonymsUser-defined data typesDatabase linksMối quan hệ giữa User và Schema là quan hệ 1 – 1, một User chỉ quản lý 1 Schema, và cũng chỉ có 1 Schema được khởi tạo khi thực thi lệnh CREATE USERUser: là một tài khoản trong cơ sở dữ liệu Oracle, sau khi được khởi tạo và gán quyền bằng lệnh CREATE USER thì tài khoản này được phép đăng nhập và sở hữu một schema trong cơ sở dữ liệuSchema: là 1 tập hợp các đối tượng trong cơ sở dữ liệu Oracle được quản lý bởi 1 user nào đó, các đối tượng của schema có thể là table, view, stored procedures, index, sequence Schema được tự động tạo cùng với user khi thực thi lệnh CREATE USER.User và tính bảo mật Account lockingTablespace quotasTemporarytablespaceDefaulttablespaceRoleprivilegesResourcelimitsSecuritydomainDirectprivilegesAuthenticationmechanismTẠO MỚI USERDanh sách các bước tạo userĐăng nhập vào user có quyền tạo user (VD: SYS, SYSTEM,v.v.)Xác định các tablespace trong đó user lưu trữ các object.Quyết định hạn mức cho mỗi tablespace.Chọn default tablespace và temporary tablespace.Tạo user.Gán quyền truy nhập cho user vừa tạo lập.TẠO MỚI USERCú pháp tạo một User mớiCREATE USER user IDENTIFIED BY password [DEFAULT TABLESPACE tablespace] [TEMPORARY TABLESPACE tablespace] [ QUOTA {integer [K|M] | UNLIMITED } ON tablespace [QUOTA {integer [K|M] | UNLIMITED} ON tablespace]...][PASSWORD EXPIRE][ACCOUNT{LOCK|UNLOCK }]CREATE USER studentIDENTIFIED BY soccerDEFAULT TABLESPACE dataTEMPORARY TABLESPACE tempQUOTA 15M ON dataQUOTA 10M ON usersPASSWORD EXPIRE;Ví dụ:Nếu không có mệnh đề default tablespace, thì default tablespace của user chính là default tablespace của database được quy định khi tạo CSDL. Gán quyền truy cập và tạo bảng cho user Gán quyền truy cập vào CSDL cho user: Grant create session to username;Khi 1 user mới được tạo ra, user đó chưa có bất cứ 1 quyền nào, chúng ta chưa thể đăng nhập vào user (vì chưa có quyền tạo session), vì vậy ta phải gán quyền create session hoặc chức danh connect cho user. Gán quyền tạo bảng cho user: Grant create table to username;Để có thể tạo bảng, user phải được cấp quyền create table, ngoài ra để tạo các đối tượng khác trong schema như sequence, trigger, procedure, ta cũng cần cấp quyền tương ứng cho user.Alter UserALTER USER user [DEFAULT TABLESPACE tablespace][ TEMPORARY TABLESPACE tablespace] [QUOTA {integer [K | M] | UNLIMITED } ON tablespace [QUOTA {integer [K|M] | UNLIMITED} ON tablespace] ...]Cú pháp:ALTER USER studentQUOTA 0 ON USERS;Ví dụ:Sau khi thay đổi hạn mức của user trên tablespace là 0, các đối tượng thuộc sở hữu user đó vẫn còn trong các tablespace, nhưng không thể cấp phát thêm một không gian mới để lưu trữ.. Ví dụ, nếu một Bảng Đó là 10MB tồn tại trong USERS tablespace, và sau đó tiến hành thay đổi hạn mức của user student trên tablespace USERS là 0, thì khi đó không thể cấp phát thêm vùng trống cho user trên USERS.Thay đổi hạn mức của user trên tablespacesAlter UserALTER USER user IDENTIFIED BY newpassword [REPLACE oldpassword];Cú phápThay đổi mật khẩu của user AMệnh đề REPLACE oldpassword: Dành cho user A khi đăng nhập thành công và thay đổi mật khẩu của chính mình.Alter UserALTER USER user ACCOUNT lock/unlock;Cú phápKhóa/Mở khóa UserHủy bỏ một UserSử dụng lệnh DROP để hủy bỏ một user.Sử dụng CASCADE để hủy tất cả các đối tượng trong schema nếu schema đó chứa các đối tượng.Các user hiện kết nối với Oracle server thì không thể hủy bỏ.DROP USER aaron;DROP USER aaron CASCADE;Lấy thông tin User Thông tin về user có thể lấy bằng cách truy vấn các view sau:DBA_USERSDBA_TS_QUOTASUSER_TS_QUOTASColumnDatatypeDescriptionUSERNAMEVARCHAR2(30)Name of the userUSER_IDNUMBERID number of the userPASSWORDVARCHAR2(30)Encrypted passwordACCOUNT_STATUSVARCHAR2(32)Account status:OPENLOCKEDDEFAULT_TABLESPACEVARCHAR2(30)Default tablespace for dataTEMPORARY_TABLESPACEVARCHAR2(30)Name of the default tablespace for temporary tables or the name of a tablespace groupCREATEDDATEUser creation dateDBA_USERSPractice : Managing Users1 Create user Bob with a password of CRUSADER. Make sure that any objects and temporary segments created by Bob are not created in the system tablespace. Also, make sure that Bob can log in and create objects up to one megabyte in size in the tablespace USERS. Hint: Assign Bob the default tablespace of USERS and temporary tablespace TEMP.2 Create a user Emi with a password of Mary. Make sure that any objects and sort segments created by Emi are not created in the system tablespace.3 Display the information on Bob and Emi from the data dictionary. Hint: This can be obtained by querying DBA_USERS.4 From the data dictionary, display the information on the amount of space that Bob can use in tablespaces. Hint: This can be obtained by querying DBA_TS_QUOTAS.5. As user Bob, change his password to Sam.6 As user SYSTEM, remove Bob’s quota on his default tablespace.7 Remove the Emi account from the database.8 Bob has forgotten his password. Assign him a password of OLINK and require that Bob change his password the next time he logs on.

Các file đính kèm theo tài liệu này:

  • pptxgiao_trinh_cong_nghe_oracle_bai_9_quan_ly_users_nguyen_viet.pptx
Tài liệu liên quan