In create table statement we saw how to create table, create table with constraints etc.In this tutorial we we will see how to insert a data into tale using INSERT INTO statement.
Once you have table ready, you need to use INSERT INTO statement to insert records in it.
If you are inserting same number of records as number of column names you can omit the column part, however it should be in the same order of column created in table.
If you are not sure about column names in table you can use DESCRIBE
CREATE TABLE employees_demo
( employee_id NUMBER(6)
, first_name VARCHAR2(20)
, last_name VARCHAR2(25)
CONSTRAINT emp_last_name_nn_demo NOT NULL
INSERT INTO employees_demo VALUES (1,”Chuck”,”Norris”);
If you try to only insert data in two column
INSERT INTO employees_demo (employee_id,first_name) VALUES (1,"Chuck","Norris");
It will through error as we have defined last_name column to be not null.
If you want to leave first_name column empty you can specify only two column in insert statement as
INSERT INTO employees_demo (employee_id,last_name) VALUES (1,"Norris");