Sunday 27 October 2013

DCL Commands and Introduction to Programming in Oracle

DCL commands are generally used in controlling the permissions of a designer on a table. there are the following commands in the DCL category:
  • Grant: This command grants permissions to the user of a database. He can be given permissions to get connected, utilize the resources like manipulation commands (insert, delete etc.,)
  •  Revoke: This is the opposite of the grant: it removes the permissions of an user on a database.

Summary of the Commands:



Creating User into Oracle:

The steps are:
  1. Download a version of Oracle database from Oracle site ( I prefer Oracle 10xe).
  2. Install The Database onto your disk, the system will start functioning as your database.
  3. Now open the Oracle command-line.
  4. The window will some what be similar to the windows command-line.


    After you have obtained the above state, go for the following sequence of commands to have your own user and password. Oracle will provide by default an username and a password, it can be chosen while installing the oracle itself. The default user can be system/system or system/manager. My notation is here of the form username/password style.

    1. connect
    2. Enter username: system
    3. Enter password: system/manager
    4. now you should get the result as "connected." Now type in
    5. create user identified by ;
    6. you'll get a sign "user created." Now type in
    7. grant connect,resources to
    8. you'll get a sign "grant succeeded." Now type in
    9. connect
    10. username:
    11. password:
    12. you'll get "connected." 
    To check whether you are in which username, type in "show user". You'll get 
    USER is

    To clear the screen, type "cl scr"


    Remember, every time you are to use your oracle, you must connect with your username and password combination. We'll now create a small table Student, with the following attributes:

    • snum : number
    • sname : string (alpha numeric)
    • class : string (pure character)
    • subject : string (alpha numeric)
    For now just think that alpha numeric can be expressed in the best way as using "varchar2" datatype in oracle. we'll discuss the datatypes in our next issue.

    the command for the above table is as:


    create table student(snum number(5), sname varchar2(10), class varchar2(5), subject varchar2(5));


    the result should be " table created".


    Now we'll insert some data into the table:


    insert into student values (1101, 'rambabu', 'section1', 'java');


    output: '1 row(s) inserted'


    update table student set snum=101 where snum=1101;


    output: '1 row(s) updated'


    delete * from student where snum=101;


    output: '1 row(s) deleted'


    select * from tab;


    output: "This shows the tables that are present in your user directory"

    No comments:

    Post a Comment