Tuesday, February 6, 2018

Rman Basic Command List

Rman Basic Command List (Easy to Understand) 

*SHOW COMMAND**

 1) show all;
 2) show archivelog deletion policy;
 3) show archivelog backup copies;
 4) show auxname;
 5) show backup optimization;
 6) show [auxiliary] channel;
 7) show channel for device type [disk | <media device>;
 8) show controlfile autobackup;
 9) show controlfile autobackup format;
 10) show datafile backup copies;
11) show default device type;
12) show retention policy;
13) show encryption algorithm;
14) show encryption for [database | tablespace];
15) show exclude;
16) show maxsetsize;
17) show retention policy;
18) show snapshot controlfile name;
19) show compression algorithm;
**BACKUP COMMAND** 
1) backup current controlfile;
2) backup tablespace users include current controlfile;
3) backup spfile;
4) backup not backed up since time ‘sysdate-1′ database plus archivelog;
5) backup database force;
6) backup database;
7) backup database plus archivelogs;
8) backup archivelog all;
9) backup datafile 5 tag dbfile_5_bkp;


**CATALOG COMMAND**

1) Add user-managed copies of datafile to RMAN repository

RMAN> catalog datafilecopy ‘/u01/oracle/users.bkp’;

RMAN> catalog datafilecopy ‘/u01/oracle/users.bkp’ level 0;  (To catalog as incremental level 0 backup)
2) Add uncataloged backup piece to RMAN repository

RMAN> catalog backuppiece ‘ertt2lu4_1_1′;

3) To catalog multiple files ( say you copied production backup to target database for database cloning)

RMAN> catalog start with ‘/backups/source_bkp’ noprompt;

The start with clause specifies that RMAN catalog all valid backup sets, datafile copies, and archived redo logs starting with the string pattern you pass.

4) To catalog all files in the flash recovery area

RMAN> catalog recovery area;

**REPORT COMMAND**

1)report need backup;
2) report schema;
 report schema at time ‘sysdate-1′;  (from a past point in time)
3) report obsolete;
 **LIST COMMAND**
1) list backup;
2) list backup by file;
3) list backupset;
4) list copy;
5) list backupset tag ‘full_database_backup’;
6) list backup of database;
7) list incarnation;
8)  list restore point;
9)  list script names;
10) list expired backup;
11) list expired archivelog all;
12) list recoverable backup;
13) list restore point all;

**CROSSCHECK COMMAND**
1) crosscheck backupset;
2) crosscheck copy of database;
3) crosscheck backupset 10, 12;
4) crosscheck backuppiece tag = ‘monthly_backup’;
5) crosscheck controlfilecopy ‘/backups/control01.ctl’;
6) crosscheck backup of datafile “/u01/oracle//system01.dbf” completed after ‘sysdate-7′;
7) crosscheck backup of archivelog all spfile;
8) crosscheck backup;

**DELETE COMMAND**
1) delete backup;
2) delete copy;
3) delete backuppiece 9;
4) delete copy of controlfile like ‘/backups/%’;
5) delete backup tag=’double_bkp_prod’;
6) delete backup of tablespace sysaux device type sbt;
******************
 Note -You can also use force, expired, obsolete keyword with delete commad:

delete force ..: Deletes the specified files whether they actually exist on media or not and removes their records from the RMAN repository as well

delete expired ..: Deletes only those files marked as expired  as per crosscheck command.

delete obsolete ..: Deletes datafile backups and copies and the archived redo logs and log backups that are recorded as obsolete in the RMAN repository
The delete obsolete command relies only on the backup retention policy in force.
******************
7) delete archivelog all;
8) delete archivelog all backed up 2 times to sbt;
9) delete archivelog until sequence = 1234;
10) backup device type sbt archivelog all delete all input;
11) delete script full_disk_db;

If you have two scripts—one local and one global—in the same name, then the delete script command drops the local one, not the global one. If you want to drop the global script, you must use the keyword global in the command, as shown here:

12)delete global script full_disk_db;

**CHANGE COMMAND**
1) change backupset 6 unavailable;
2)   change backupset 6 available;
3) change backup tag ‘initial_db_bkup’ keep forever;
4) change backup tag ‘inital_db_backup’ nokeep;
5) change backupset 12 keep until time ‘sysdate+60′;

**VALIDATE COMMAND**
1) backup validate database archivelog all;
2)  backup validate check logical database archivelog all;
3) validate backupset 5;
4) validate database;
5)  validate recovery area;
6) validate recovery files;
7) validate spfile;
8) validate tablespace <tablespace_name>;
9) validate controlfilecopy <filename>;
10) validate backupset <primary_key>;


Monday, February 5, 2018

User And Their Privilege

  How to Create a User and Grant Permissions in Oracle

       Description

       The CREATE USER statement creates a database account that allows you to log into the                    Oracle database.

        Creating a User


       CREATE USER CAG
        IDENTIFIED BY xyz
         DEFAULT TABLESPACE USERS
         PROFILE DEFAULT
        ACCOUNT UNLOCK;

            NOTE --Parameters or Arguments

1             1)    user_name

The name of the database account that you wish to create
.
2               2)      TABLESPACE

Optional , It is the name of the tablespace that you wish to assign to the users.

3               3)      PROFILE profile_name

Optional. It is the name of the profile that you wish to assign to the user account to limit the amount of database resources assigned to the user account. If you omit this option, the DEFAULT profile is assigned to the user.
4               4)      PASSWORD EXPIRE

Optional. If this option is set, then the password must be reset before the user can log into the Oracle database.
           5) ACCOUNT LOCK

Optional. It disables access to the user account.

            6) ACCOUNT UNLOCK

  Optional. It enables access to the user account

    The Grant Statement


With our new CAG account created, we can now begin adding privileges to the account using the GRANT statement. GRANT is a very powerful statement with many possible options, but the core functionality is to manage the privileges of both users and roles throughout the database.

 Providing Roles

Typically, you’ll first want to assign privileges to the user through attaching the                   account to  various roles, starting with the CONNECT role:       
GRANT CONNECT TO CAG;
In some cases to create a more powerful user, you may also consider adding the RESOURCE role (allowing the user to create named types for custom schemas) or even the DBA role, which allows the user to not only create custom named types but alter and destroy them as well.
GRANT CONNECT, RESOURCE, DBA TO CAG;

Assigning Privileges

Next you’ll want to ensure the user has privileges to actually connect to the database and create a session using GRANT CREATE SESSION. We’ll also combine that with all privileges using GRANT ANY PRIVILEGES.
GRANT CREATE SESSION GRANT ANY PRIVILEGE TO CAG;
We also need to ensure our new user has disk space allocated in the system to actually create or modify tables and data, so we’ll GRANT TABLESPACE like so:
GRANT UNLIMITED TABLESPACE TO CAG;

Table Privileges

While not typically necessary in newer versions of Oracle, some older installations may require that you manually specify the access rights the new user has to a specific schema and database tables.
For example, if we want our CAG user to have the ability to perform SELECT, UPDATE, INSERT, and DELETE capabilities on the books table, we might execute the following GRANT statement:
GRANT
  SELECT,  INSERT,  UPDATE,  DELETE ON   schema.books
TO
  CAG;
This ensures that CAG can perform the four basic statements for the books table that is part of the schema schema.




How to create user in MY SQL

Create  a new MySQL user Account mysql > CREATE USER ' newuser '@'localhost' IDENTIFIED BY ' password '...