Difference between revisions of "Insert Command"
Jump to navigation
Jump to search
Line 3: | Line 3: | ||
INSERT INTO accountmanager | INSERT INTO accountmanager | ||
VALUES ('T500', 'NICK', 'TAYLOR', '05-SEP-09', 4200, 3500, 'NE'); | VALUES ('T500', 'NICK', 'TAYLOR', '05-SEP-09', 4200, 3500, 'NE'); | ||
''' Insert With column Names | ''' Insert With column Names Null values at the end.''' | ||
INSERT INTO acctmanager(amid, amfirst, amlast, amedate, amsal, acomm) | INSERT INTO acctmanager(amid, amfirst, amlast, amedate, amsal, acomm) | ||
VALUES ('T500', 'NICK', 'TAYLOR', '05-SEP-09', 4200, 3500, ''); | VALUES ('T500', 'NICK', 'TAYLOR', '05-SEP-09', 4200, 3500, ''); | ||
Line 13: | Line 13: | ||
insert into acctmanager(amid, amfirst, amlast, amedate, amsal, amcoMm, region) | insert into acctmanager(amid, amfirst, amlast, amedate, amsal, amcoMm, region) | ||
values ('R500', 'ROBERT', 'JONES', SYSDATE, 50000, 1000, 'NW') | values ('R500', 'ROBERT', 'JONES', SYSDATE, 50000, 1000, 'NW') | ||
=== Add Virtual Column === | |||
ALTER TABLE acctmanager | |||
ADD (amearn AS (amsal + amcomm)); | |||
=== Add name with an apostrophe - Use two single quotes === | |||
insert into acctmanager(amid, amfirst, amlast, amedate, amsal, amcoMm, region) | |||
values ('R500', 'ROBERT', 'O''HARA', SYSDATE, 50000, 1000, 'NW') | |||
=== Inserting data from an existing table using a subquery === |
Revision as of 01:14, 18 October 2017
Insert
Adds new rows to a table, can include subquery to copy rows from an existing table
INSERT INTO accountmanager VALUES ('T500', 'NICK', 'TAYLOR', '05-SEP-09', 4200, 3500, 'NE'); Insert With column Names Null values at the end. INSERT INTO acctmanager(amid, amfirst, amlast, amedate, amsal, acomm) VALUES ('T500', 'NICK', 'TAYLOR', '05-SEP-09', 4200, 3500, );
INSERT INTO acctmanager(amid, amfirst, amlast, amedate, amsal, acomm) VALUES ('T500', 'NICK', 'TAYLOR', '05-SEP-09', 4200, 3500, NULL);
Use System date as an entry
insert into acctmanager(amid, amfirst, amlast, amedate, amsal, amcoMm, region) values ('R500', 'ROBERT', 'JONES', SYSDATE, 50000, 1000, 'NW')
Add Virtual Column
ALTER TABLE acctmanager ADD (amearn AS (amsal + amcomm));
Add name with an apostrophe - Use two single quotes
insert into acctmanager(amid, amfirst, amlast, amedate, amsal, amcoMm, region) values ('R500', 'ROBERT', 'OHARA', SYSDATE, 50000, 1000, 'NW')