Creating Table
Table is collection of Columns and Rows. Each column required name, data type and length or precision. To create a table, first structure of table should be defined with a name. Then required rows should be insterted in to TABLE.
CREATE Table in ORACLE database
CREATE TABLE EMPLOYEE_INCOME
(EMPID NUMBER(10),
NAME VARCHAR2(20),
SALARY NUMBER(10));
Executing above SQL CREATE TABLE statement will create the following table structure with name EMPLOYEE_INCOME:
ALTER TABLE in ORACLE database
ALTER TABLE EMPLOYEE_INCOME
ADD BONUS NUMBER(10);
Executing above SQL ALTER TABLE statement will add the bonus column to existing EMPLOYEE_INCOME table, now it looks like the following:
SQL to INSERT RECORDS in to TABLE
INSERT INTO EMPLOYEE_INCOME
(EMPID, NAME, SALARY, BONUS)
VALUES
(1, 'Bill', 10000, 1000);
EMPID |
NAME |
SALARY |
BONUS |
1 |
Bill |
10000 |
1000 |
INSERT ALL
INTO EMPTBL (EMPID, NAME, SALARY, BONUS) VALUES (1, 'Bill', 10000, 1000)
INTO EMPTBL (EMPID, NAME, SALARY, BONUS) VALUES (2, 'Mike', 20000, 2000)
INTO EMPTBL (EMPID, NAME, SALARY, BONUS) VALUES (3, 'Samson', 30000, 3000)
INTO EMPTBL (EMPID, NAME, SALARY, BONUS) VALUES (5, 'Kevin', 50000, 5000)
SELECT * FROM EMPLOYEE_INCOME;
EMPID |
NAME |
SALARY |
BONUS |
1 |
Bill |
10000 |
1000 |
2 |
Mike |
20000 |
2000 |
3 |
Samson |
30000 |
3000 |
5 |
Kevin |
50000 |
5000 |
Create another table named: EMPLOYEE_DETAILS with the data by following above setps
EMPID |
NAME |
CITY |
1 |
Bill |
Los Angeles |
2 |
Mike |
Los Angeles |
3 |
Samson |
Portland |
4 |
John |
Orlando |