What is projection operation in DBMS?
Projection operation (represented by
Syntax
The syntax of projection is as follows:
Where A1 and A2 are attribute names and
The result is defined as the relation of
Example
Consider the following table (named Instructors) on which the projection operation would be applied:
Instructors
ID | Name | Salary |
10101 | Addie | 65000 |
12121 | Bob | 52000 |
22222 | John | 70000 |
44444 | Mary | 40000 |
If we want to get only the "Salary" column from the "Instructors" table, we'll perform the following command:
The above command would produce the following results:
Salary |
65000 |
52000 |
70000 |
40000 |
Similarly, we can also project multiple columns from the table. If we want to display ID and their respective name (eliminate the "Salary" column), we'll perform the following operation:
The command would produce the following output:
ID | Name |
10101 | Addie |
12121 | Bob |
22222 | John |
44444 | Mary |
Projection operation in SQL
SELECT ID, NameFROM Instructors
Free Resources