1. Trang chủ
  2. » Thể loại khác

Quản lý người dùng trong sql

13 11 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

BÀI GIẢNG ORACLE QUẢN LÝ USERS 1 1 Mục đích Mục đích Sau 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ó[.]

QUẢN LÝ USERS Mục đích Mục đích • Sau hồn thành học này, bạn có thể: • • • • Tạo database user Thay đổi hủy bỏ database user có Kiểm sốt thơng tin user có Lấy thơng tin user Database Schema • User: tài khoản sở liệu Oracle, sau khởi tạo gán quyền lệnh CREATE USER tài khoản phép đăng nhập sở hữu schema sở liệu • Schema: tập hợp đối tượng sở liệu Oracle quản lý user đó, đối tượng schema table, view, stored procedures, index, sequence… Schema tự động tạo với user thực thi lệnh CREATE USER • Mối quan hệ User Schema quan hệ – 1, User quản lý Schema, có Schema khởi tạo thực thi lệnh CREATE USER Schema Objects Tables Triggers Constraints Indexes Views Sequences Stored program units Synonyms User-defined data types Database links User tính bảo mật Account locking Default tablespace Temporary tablespace Authentication mechanism Security domain Role privileges Direct privileges Tablespace quotas Resource limits TẠO MỚI USER  Danh sách 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 tablespace user lưu trữ object Quyết định hạn mức cho tablespace Chọn default tablespace temporary tablespace Tạo user Gán chức danh truy nhập cho user vừa tạo lập TẠO MỚI USER  Cú pháp tạo User CREATE 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 }] Ví dụ: CREATE USER student IDENTIFIED BY soccer DEFAULT TABLESPACE data TEMPORARY TABLESPACE temp QUOTA 15M ON data QUOTA 10M ON users PASSWORD EXPIRE; Nếu khơng có mệnh đề default tablespace, default tablespace user default tablespace database quy định tạo CSDL Gán chức danh truy nhập cho user CONNECT/RESOURCE Cú pháp: Grant connect,resource to username; Khi user tạo ra, user chưa có quyền nào, chưa thể đăng nhập vào user (vì chưa có quyền tạo session), ta phải gán chức danh connect cho user Role Resource: cho phép tạo đối tượng user Alter User Thay đổi hạn mức user tablespaces Cú pháp: ALTER USER user [DEFAULT TABLESPACE tablespace][ TEMPORARY TABLESPACE tablespace] [QUOTA {integer [K | M] | UNLIMITED } ON tablespace [QUOTA {integer [K|M] | UNLIMITED} ON tablespace] ] Ví dụ: ALTER USER student QUOTA ON USERS; Sau thay đổi hạn mức user tablespace, đối tượng thuộc sở hữu user cịn tablespace, cấp phát thêm không gian để lưu trữ Ví dụ, Bảng Đó 10MB tồn USERS tablespace, sau tiến hành thay đổi hạn mức user student tablespace USERS 0, khơng thể cấp phát thêm vùng trống cho user USERS Alter User  Thay đổi mật user A Cú pháp ALTER USER user IDENTIFIED BY newpassword [REPLACE oldpassword];  Mệnh đề REPLACE oldpassword: Dành cho user A đăng nhập thành cơng thay đổi mật Alter User  Khóa/Mở khóa User Cú pháp ALTER USER user ACCOUNT lock/unlock; Hủy bỏ User • Sử dụng lệnh DROP để hủy bỏ user DROP USER aaron; • Sử dụng CASCADE để hủy tất đối tượng schema schema chứa đối tượng DROP USER aaron CASCADE; • Các user kết nối với Oracle server khơng thể hủy bỏ Lấy thơng tin User DBA_USERS Thơng tin user lấy cách truy vấn view sau: • DBA_USERS • DBA_TS_QUOTAS • USER_TS_QUOTAS Column USERNAME USER_ID Datatype VARCHAR2(30) NUMBER Description Name of the user ID number of the user PASSWORD ACCOUNT_STATUS VARCHAR2(30) VARCHAR2(32) Encrypted password •Account status:OPEN •LOCKED •… DEFAULT_TABLESPACE VARCHAR2(30) Default tablespace for data TEMPORARY_TABLESPACE VARCHAR2(30) Name of the default tablespace for temporary tables or the name of a tablespace group CREATED DATE User creation date Practice : Managing Users 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 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 Display the information on Bob and Emi from the data dictionary Hint: This can be obtained by querying DBA_USERS 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 As user Bob, change his password to Sam As user SYSTEM, remove Bob’s quota on his default tablespace Remove the Emi account from the database Bob has forgotten his password Assign him a password of OLINK and require that Bob change his password the next time he logs on ... Oracle quản lý user đó, đối tượng schema table, view, stored procedures, index, sequence… Schema tự động tạo với user thực thi lệnh CREATE USER • Mối quan hệ User Schema quan hệ – 1, User quản lý

Ngày đăng: 19/11/2022, 21:01

Xem thêm:

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN