Pr.Pg Next Pg

Insert data in to the table using Query in SQL Developer tutorials

 

  • Write the query in SQL worksheet, we have ACCOUNT_MASTER1 table (we have already created in previously) the

 

SQL statement for Insert data in to the ACCOUNT_MASTER1 table

 

INSERT INTO ACCOUNT_MASTER1 (ACCOUNT_CODE,ACCOUNT_TYPE,NAME,ADD1,ADD2,ADD3,CITY,PIN,STATE,COUNTRY,EMAIL) VALUES('AC001','Supplier','Jack','306 jr bldng','VB Road ','xyz','hhd',4064,'Washington','USA','jacktest@rediffmail.com');

 

  • Similarly we can insert multiple records in to the ACCOUNT_MASTER table.

 

INSERT INTO ACCOUNT_MASTER1

(ACCOUNT_CODE,ACCOUNT_TYPE,NAME,ADD1,ADD2,ADD3,CITY,PIN,STATE,COUNTRY,EMAIL)

VALUES('AC002','Supplier','wilson','410 Diamond bldng','Jupiter Hotel','dgh','kjg',0075,'Cambridge','UK','prakash@gmail.com');

OR

INSERT INTO ACCOUNT_MASTER

VALUES('AC002','Supplier','wilson','410 Diamond bldng','Jupiter Hotel','dgh','kjg',0075,'Cambridge','UK','prakash@gmail.com');

 

Now display the inserted record from the ACCOUNT_MASTER1 table, the query will be

SELECT * FROM ACCOUNT_MASTER1;

  • The result set will look like that.

 


  • Now we want to create a new table SUPPLIER with PRIMARY KEY SUPPLIER_ID.

  • Primary key: A Primary Key is used to uniquely identify each row in a table. It acts to enforce row-level integrity of the table, meaning that it ensures that there are no duplicate records in a table.

 

The SQL statement for create SUPPLIER table:

 

CREATE TABLE SUPPLIER

( "SUPPLIER_ID" VARCHAR2(10),

"SUPPLIER_NAME" VARCHAR2(30),

"ADD1" VARCHAR2(30),

"ADD2" VARCHAR2(30),

"MOBILE" NUMBER(10,0),

"EMAIL" VARCHAR2(50),

"ZIPCODE" NUMBER(10),

"STATE" VARCHAR2(30),

CONSTRAINT supplier_pk PRIMARY KEY (SUPPLIER_ID)

);

 

Now insert the records in to the SUPPLIER table the following query is

 

INSERT INTO SUPPLIER

VALUES ('SP1100','Mr.Jimm','xyz road','Hotel b town',02475,'jimmtest@yahoo.com',5325804,'Bristol');

INSERT INTO SUPPLIER

VALUES ('SP1101','Headword','123 road','near max',645689,'headtest@gmail.com',10003,'Chester');

INSERT INTO SUPPLIER

VALUES ('SP1102','B.Stone','Road no 23','Plaza hotel',1485372,'bstone_test@yahoo.co.in',40092,'City of London');

 

Now display the inserted record from the SUPPLIER table, the following query will be

 

SELECT * FROM SUPPLIER;

  • The result set will look like that.

 


Pr.Pg border                                              Next Pg