COMMANDS USED IN A TABLE:-
CREATE TABLE COMMAND
The CREATE TABLE command includes a single clause for the column definition. Each column is a parameter for the clause and thus it is separated by comma.
SYNTAX: -
CREATE TABLE tablename
( columnname datatype(size), columnname datatype (size));
EXAMPLE: -
SQL>CREATE table banking(name varchar2(10), address archar2(20), accountno number(10,0), amount number(10,0),id varchar2(10));
Table created.
INSERTION OF DATA INTO TABLES
Once a table is created the most natural thing to do is load this table with data to be manipulated later.
When inserting a single row of data into the table, the insert operation: -
Creates a new row in the database table
Loads the values passed into all the columns specified.
SYNTAX: -
INSERT INTO tablename(columnname, columnname)
VALUES (expression, expression);
EXAMPLE: -
SQL> insert into banking(name,address,accountno,amount,id) values ('ABC','899-House',27207,90000,'10900');
1 row created.
VIEWING DATA IN THE TABLE
Once data has been inserted into a table, the next most logical operation would be to view what has been entered. The ‘SELECT’ SQL verb is used to achieve this.
(1) All rows and all columns:
When data from certain rows and column from table is to be viewed.
SYNTAX: -
SELECT (columnname1……….columnname n) FROM tablename;
EXAMPLE: -
SQL> select name, address,id from banking;
(2) When data from all rows and columns from table are to be viewed.
SYNTAX: -
SELECT * FROM tablename;
EXAMPLE: -
SQL> select * from employee;
3)With Where Condition
SYNTAX: -
SELECT * FROM tablename WHERE search conditions;
EXAMPLE: -
SQL> select * from banking where accountno > 290;
4) SYNTAX: -
SELECT columnname, columnname
FROM tablename
WHERE search condition;
EXAMPLE: -
SQL> select accountno, amount,id from banking where amount>60000;
CREATE TABLE COMMAND
The CREATE TABLE command includes a single clause for the column definition. Each column is a parameter for the clause and thus it is separated by comma.
SYNTAX: -
CREATE TABLE tablename
( columnname datatype(size), columnname datatype (size));
EXAMPLE: -
SQL>CREATE table banking(name varchar2(10), address archar2(20), accountno number(10,0), amount number(10,0),id varchar2(10));
Table created.
INSERTION OF DATA INTO TABLES
Once a table is created the most natural thing to do is load this table with data to be manipulated later.
When inserting a single row of data into the table, the insert operation: -
Creates a new row in the database table
Loads the values passed into all the columns specified.
SYNTAX: -
INSERT INTO tablename(columnname, columnname)
VALUES (expression, expression);
EXAMPLE: -
SQL> insert into banking(name,address,accountno,amount,id) values ('ABC','899-House',27207,90000,'10900');
1 row created.
VIEWING DATA IN THE TABLE
Once data has been inserted into a table, the next most logical operation would be to view what has been entered. The ‘SELECT’ SQL verb is used to achieve this.
(1) All rows and all columns:
When data from certain rows and column from table is to be viewed.
SYNTAX: -
SELECT (columnname1……….columnname n) FROM tablename;
EXAMPLE: -
SQL> select name, address,id from banking;
(2) When data from all rows and columns from table are to be viewed.
SYNTAX: -
SELECT * FROM tablename;
EXAMPLE: -
SQL> select * from employee;
3)With Where Condition
SYNTAX: -
SELECT * FROM tablename WHERE search conditions;
EXAMPLE: -
SQL> select * from banking where accountno > 290;
4) SYNTAX: -
SELECT columnname, columnname
FROM tablename
WHERE search condition;
EXAMPLE: -
SQL> select accountno, amount,id from banking where amount>60000;