Dream up a database simple and practical examples

Dream up a database simple and practical examples

First, the operating system installed Kylin DaMeng database (Kylin operating system and database DaMeng installation package is available at the corresponding official website)

(By the way, after all, is done on the Kylin operating system operation, so commonly used linux commands or to understand the point of ^ _ ^; (mkdir useradd groupadd passwd chmod chown ls cp))

Second, after the installation of the database, how to use the database up to the dream? Here's the simple steps this record this operation (some common examples of operations on the table space and the user)

Table space:

A. Create a table space
Case 1:
Create a table space tbs, data files to $ DM_HOME / data / DB_NAME, the initial file size is 31M.
Error: SQL> create tablespace tbs datafile ' /dm7/data/DAMENG/TBS.dbf' SIZE 31;
initial file size of the page is 4096 times.
Case 2:
Create a table space TBS2, require two data files, are stored on different Disk, initial size of 32M, a single large file 100M.
SQL> create tablespace tbs2 datafile '/dm7/data/DAMENG/disk1/TBS2_1.dbf ' size 32 autoextend on 100, '/ dm7 / data / DAMENG / disk2 / TBS2_2.dbf' size 32 autoextend maxsize on maxsize 100;
find available table space size?
SQL> select tablespace_name, bytes / 1024 /1024 from dba_free_space where tablespace_name = 'TBS2';
do not specify the size of the expansion is the number?
SQL> the SELECT Page;
SQL> sf_get_extent_size the SELECT ();
Case 3:
Planning table space tbs3, initial file size 32M, each expansion 1M, maximum 33M.
SQL> create tablespace tbs3 datafile '/dm7/data/DAMENG/tbs3.dbf' size 32 autoextend on next 1 maxsize 33;

B. how to maintain and manage table space?
1. Table space is insufficient
A. Create a large table space data in the import export
B. table space data file of a resize
C. increases data files
SQL> alter tablespace tbs3 add datafile ' /dm7/data/DAMENG/tbs3_1.dbf' size 32 50 ON MAXSIZE AUTOEXTEND;
2. tablespace replacement storage location
SQL> select tablespace_name, file_name from dba_data_files where tablespace_name = 'TBS';
Note: tablespace removable storage position, the table space required Offline
the SQL> SELECT tablespace_name, Status from DBA_TABLESPACES;
0 represents is online, 1 is a table Offline
the SQL> ALTER TABLESPACE TBS Offline;
the SQL> ALTER TABLESPACE TBS the rename datafile '/dm7/data/DAMENG/TBS.dbf' to '/dm7/tbs/TBS.dbf';
the SQL> TBS Online tABLESPACE the ALTER;
3. delete table space
SQL> drop tABLESPACE tbs3;
drop tABLESPACE tbs3;

SQL> drop tablespace tbs;

User
1. What are the default user?
SQL> select username from dba_users;
line numbers USERNAME


1 SYS (built-in administrative accounts can not log database)
2 SYSDBA (administrator)
3 SYSAUDITOR (Auditor)
4 SYSSSO (security officer - Security)
version:
SQL> the SELECT * from v $ Version;
development versions, Standard Edition, enterprise Edition, security
2. plan user?
Name begins with the letter A. # _ $
B. storage location table space
C. password security policy (login attempts, lockout time, the password is valid)
D. privileges (system object)
Plan user test, the user's default table space for tbs2, password attempts to log on three times, failed to lock one minute, the password is valid 180 days. You can create a table, you can query all data dmhr.city table.
SQL> create user test identified by " dameng123" limit FAILED_LOGIN_ATTEMPS 3, password_lock_time 1, password_life_time 180 default tablespace tbs2;
Authorization:
What do system privileges on the database?
What do the data object rights object database?
SQL> Grant the Create the Table to the Test;
SQL> Grant the SELECT ON dmhr.city to the Test;
revoke privileges:
SQL> REVOKE the Create the Table from the Test;
SQL> REVOKE the SELECT ON dmhr.city from the Test;
3. planning role? (A kind of collection authority)
public Resource DBA
the SQL> Create Role R1;
the SQL> Grant Create Table to R1;
the SQL> SELECT ON dmhr.city Grant to R1;
the SQL> Grant R1 to Test;
determining user's rights:
the SQL> SELECT GRANTEE, granted_role from DBA_ROLE_PRIVS WHERE GRANTEE = 'the TEST';
the SQL> GRANTEE SELECT, WHERE GRANTEE = Privilege from DBA_SYS_PRIVS 'Rl';
4. maintaining user and role?
A. Change Password
SQL> the ALTER the Test IDENTIFIED by the User 123456789;
B. locked and unlocked
SQL> the ALTER the Test the Account the User Lock;
SQL> the SELECT username, ACCOUNT_STATUS from dba_users;
SQL> the ALTER the Test the Account the User UNLOCK;
C. delete user
SQL> drop the Test the User;
SQL>
D. enable and disable role
SQL> sp_set_role ( 'R1', 0);
SQL> sp_set_role ( 'R1', 1);
E. delete role
SQL> drop role r1;
Note: When creating a user generates a user with the same name mode, if you create a user, model name already exists, the user can not be created.

Guess you like

Origin blog.51cto.com/14614041/2450224