➤ On the Employee table use the many faces of Select Command.
Select Command can be categorized in many ways given below-
1. Select all columns data from table without condition.
2. Select specific Columns data from table without Condition.
3. Select all columns data from table with Condition.
4. Select specific Columns data from table with Condition.
Let us fire the queries of each by given below steps -
1. Create table Employee
SQL> CREATE TABLE Employee
(
Emp_ID int,
EName varchar(20),
Age int,
Department char(10)
);
Table Created.
2. Insert record into the Employee Table
SQL> INSERT INTO Employee VALUES(1,'Tanu', 20, 'HR');
1 Row Created.
SQL> INSERT INTO Employee VALUES(2,'Shreya', 19, 'Caller');
1 Row Created.
SQL> INSERT INTO Employee VALUES(3,'Roshni', 26, 'Manager');
1 Row Created.
3. Now we can apply different faces of Select Command.
A. Select all columns data from table without condition by below query.
SQL> SELECT * FROM Employee;
Emp_ID | EName | Age | Department |
1 | Tanu | 20 | HR |
2 | Shreya | 19 | Caller |
3 | Roshni | 26 | Manager |
B. Select specific Columns data from table without Condition by below query.
SQL> SELECT EName, Age FROM Employee;
EName | Age |
Tanu | 20 |
Shreya | 19 |
Roshni | 26 |
C. Select all columns data from table with Condition by below query.
SQL> SELECT * FROM Employee WHERE Emp_ID=2;
Emp_ID | EName | Age | Department |
2 | Shreya | 19 | Caller |
D. Select specific Columns data from table with Condition by below query.
EName | Age |
Shreya | 19 |
No comments:
Post a Comment