Concatenation Operator
This Operator is used in SQL to link columns or character string to other columns.
It is represented by two vertical bars ( || ) and the result is always a character expression.
For eg. we can concat the FIRST_NAME and the LAST_NAME columns in EMPLOYEES table.
SELECT first_name||last_name FROM employees;
Literals in SQL
A Literal is nothing but a character or a date or a number which is included in a SQL Statement.
The date and characters must be enclosed in single quotes (' ').
Each Character string is outputted once for each row returned by the query.
Below query will display the first name of all the employees along with there job id using a character
literal 'is a' to improve readability.
SELECT first_name||' is a '||last_name "Employees" FROM employees;
Distinct
By default a SQL will always display all the rows including duplicates.
To eliminate the duplicate rows we include the DISTINCT keyword in SELECT clause after the
SELECT keyword.
First Query result contains duplicate department id's as we have not used the DISTINCT keyword.
whereas, the second query removes all the duplicate department id's as we have used the DISTINCT keyword in our query.
SELECT department_id FROM employees;
Display Table Structure
Using the DESCRIBE command we can display the structure of the table.
Describe command is a SQL PLUS command.
DESCRIBE employees;
or
DESC employees;
DESCRIBE employees;
or
DESC employees;