Oracle
Oracle
* Not in Syllabus
Create Table:
Create table command defines each column of the table uniquely. Each column has
minimum of three attributes a name, data type and size. Each table
Syntax:
CREATE TABLE <tableName> (<columnName1> <DataType (<size>),
<columnName2> <DataType (<size>));
Example
CREATE TABLE bcom4 (rollno number(4), name varchar2(30), marks number(3));
Above example create a table with 3 fields (columns) rollno, name and marks. Currently
there is no data inside this table. Create table only create the structure of table.
DML Commands :
Insert:
When a table is created for the very first time it is an empty structure. The next
thing to do is to load this empty structure with business data to be manipulated
later.
Loading table data can be done using the SQL INSERT statement which:
Creates a new empty row in the database table
Loads the values embedded within the SQL Insert statement into the
empty row
The following is the syntax for inserting the data or value into the table.
Syntax:
INSERT INTO <TableName> (<ColumnName1>, <ColumnName2>)
VALUES (<Expression1>, <Expression2>);
Update:
The UPDATE command is used to change or modify data values in a table.
The UPDATE verb in SQL is used to either update:
All the rows in a table
OR
A specific set of rows in a table
The following is the syntax for updating specific row of data in the table.
Syntax:
Update <TableName>
SET <ColumnName1>=<Expression1>, <ColumnName2>=<Expression2>
WHERE <Condition>;
Delete:
The DELETE command deletes rows from the table that satisfies the condition
specified in its WHERE clause and returns the number of records deleted.
If a DELETE statement without a WHERE clause is fired then all rows in the
table are deleted.
OR
The following is the syntax for deleting specific rows from the table.
Syntax:
DELETE FROM <TableName> WHERE <Condition>;
Delete:
The DELETE command deletes rows from the table that satisfies the condition
specified in its WHERE clause and returns the number of records deleted.
If a DELETE statement without a WHERE clause is fired then all rows in the
table are deleted.
OR