SQL Plus For INSERTING Data

 SQL Plus used for managing database Object on Oracle Database. For accessing SQL Plus you can use command prompt on Windows Operating System. Open CMD from command prompt then type:

SQLPLUS / AS SYSDBA;

You can login using your own defined username by following instructions on http://www.developapex.com/2016/10/managingbasic-user-privileges-on-oracle.html . Form example if you create user with name mi123 with user mi123 you can type the following syntax:

SQLPLUS mi123/mi123;

The INSERT command has a rule value (must be the value) must have the same number, data type and sequence with the attribute (column name) of the table to which it belongs. If the structure of the destination table is known for certain amount, data type and sequence then the column name / attribute can be excluded.

Format:
INSERT INTO <tabel_name> (<attribut(es)>)
VALUES (<value(s)>);

Example:
INSERT INTO tstudent (sid, name, phone) VALUES (101, ’One’, 111111);

Explanations :
INSERT INTO tstudent -> Perform the insert command into the tstudent table.

(sidm name, phone) -> Target attributes to do the addition of data, the order of attributes really need to be considered.

VALUES (101, ‘One’, 111111) -> The value 101 is inputted into the SID attribute, the value 'One' is inputted into the name attribute, the value '111111' is inputted into the phone attribute. These three values generate a new row of data in the table.

; (titik koma) -> Denotes the end of a SQL command.

Now please fill in the following data into the TSTUDENT table by using the INSERT command like the example above:

SID
NAME
PHONE
101
One
111111
102
Two
222222
103
Three
333333

Thus one uses the INSERT command on DML. Explanation of other INSERT commands and other DML commands will be discussed in the next article.

Thank You, Bobsis.

No comments

Powered by Blogger.