Insert Into Table SQL

This article will discuss about insert into table SQL. INSERT command is used to add / insert one or more rows of data into one or more tables in a database. In the Oracle database, INSERT command must always ends with a COMMIT command to stored data permanently into the table, otherwise it will only be stored in the active session.




First create a table named TUser as follows:
CREATE TABLE TUser(
id NUMBER NOT NULL,
name VARCHAR(64),
phone VARCHAR(16),
CONSTRAINT pk_mhs PRIMARY KEY (id)
);

INSERT command has a rule values (value field) which are the values inserted must exactly match with the data type and the order of the attributes (columns name) in the heading the table. If the destination table structure has been known for sure of the column sequence and the type of data, then writing the name of the column / attribute might be excluded. Here is the format, along with examples of the use of the INSERT statement in Oracle Database.

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

Example :
INSERT INTO tuser (id, name, phone) VALUES ('MI010058', 'Boby Siswanto', '081573773406');

Explanations :
INSERT INTO tuser : perform insert commands into tuser table.

(id, name, phone) : attribute intended to perform additional data, the order of attributes is very Noteworthy

VALUES ('MI010058', ’Boby Siswanto', '081573773406') : value 'MI010058' entered into ”nim” attribute, value 'Adbul Hakim' entered into ”name” attribute, the value of '081573773406' entered into ”phone” attribute. These values will generate new data row in the tuser table.

; (Semicolon) -> signifies the end of an SQL command.

For further reading about insert into table SQL you can read here Insert Data Into Table SQL

Thank You - Bobsis

No comments

Powered by Blogger.