Friday 21 August 2015

What is schema? What are the objects created by user?

Hi friends, Today we are gonna to talk about schema. Schema is nothing but user is called as schema. A user in oracle database is called schema and objects created by user are called schema objects.
When we installer oracle on a system that system called oracle server. In that server database is created. In that database user is created. And then after in that user object are created.


Database crated by oracle installer also create some schema/ User.

            ORCL (Password)                                                     XE (Password)                                    

            SYS (asked at the time of installation)                 SYS (asked at the time of installation)
            SYSTEM (asked at the time of installation)         SYSTEM (asked at the time of installation)
            SCOTT/TIGER                                                                   HR/HR
            SH/SH
            HR/HR
            OE/OE

In this both SYS and SYSTEM are DBA and rest of all are normal user. Now lets see that what are the objects crated by user?
  1. Table
  2. Views
  3. Synonyms
  4. Sequences
  5. Indexes
  6. Clusters
  7. Materialised views
  8. Types
  9. Procedures
  10. Functions
  11. Packages
  12. Triggers
Now lets know how to connect to oracle server?
--> Open Sqlplus (You can type "sqlplus" without quotes in run or we can also find it in start menu.)
--> After that submit details asked by sqlplus. It will look like this:


Password is not visible here due to security. User name is not case sensitive but password is case sensitive here. We have one more way to connect to database. That is:


Here the format is in the form of: USERNAME/PASSWORD@DATABASE. Here database name is optional is there is only one database exist in system. If more than one database in system there then we must to enter database name.

Now lets move on creating schema/user/account.

Only DBA have permissions to create user.
Syntax:
CREATE USER <User_Name> IDENTIFIED BY <Password>


User is create here but this user is called dummy user. Because it will not be having permissions . Permissions must be granted to user by DBA using "GRANT" command.


Here we are giving two permission to "Oracle_Gang" that is CONNECT and RESOURCE. Connect will allow the user to connect to the oracle server but if we need to done some operation like create table, retrieve data from table etc then we must need resource available for that user.. Now lets drop the user. 
Syntax:
DROP USER <User_Name> [CASCADE] ;


Dropping user means that user is no longer available in database. Here any think given in "< >" then it will be considered as given by user. In that place user can enter any name. It's on up-to user. CASCADE is required if there is data available or we can say that if object created by by user then "CASCADE" is required. If no object is created by user then it is not need to give there.
For now that's all. In next post we will know about datatype available in oracle....

No comments: