Write SQL INSERT queries.
Create Table script
create table Customer (ID number constraint customer_pk primary key,Name varchar2(20));/
Query: Insert query with Primary key fields
insert into Customer (ID,Name) values(1,'Ram');insert into Customer (ID,Name) values(2,'Henry');insert into Customer (ID,Name) values(3,'Sam');insert into Customer (ID,Name) values(4,'Shyam')
Result:
Table: Customer+----+-------+| Id | Name |+----+-------+| 1 | Ram || 2 | Henry || 3 | Sam || 4 | Shyam |+----+-------+
Query: Insert query if a primary key is autogenerated
insert into Customer (Name) values('Ram');insert into Customer (Name) values('Henry');insert into Customer (Name) values('Sam');insert into Customer (Name) values('Shyam');
Result:
Table: Customer+----+-------+| Id | Name |+----+-------+| 1 | Ram || 2 | Henry || 3 | Sam || 4 | Shyam |+----+-------+
Query: Insert query without defining the column name
insert into Customer values(1,'Ram');insert into Customer values(2,'Henry');insert into Customer values(3,'Sam');insert into Customer values(4,'Shyam')
Result:
Table: Customer+----+-------+| Id | Name |+----+-------+| 1 | Ram || 2 | Henry || 3 | Sam || 4 | Shyam |+----+-------+
Related post
- Write SQL statement to create a table
- Create a table from another table with data, without data, filtered data, and specific columns
No comments:
Post a Comment