Alias name

     A column alias name is an alternative name given to the column in a select statement.It is used to rename a column heading in select statement and it allows the user to understand the output easily.

Syntax:
    Select column_name AS "Alias Name" from table_name ;

   The keyword AS used between the column name and alias name is optional.we can give the blank space instead of AS keyword.Requires double quotation marks if it contains spaces or special characters or if it is case sensitive.

Example :
SELECT last_name as name ,commission_pct as comm  FROM     employees;

SELECT last_name as name ,salary*12 "Annual Salary"  as comm  FROM     employees;















Default column heading :
  • Character and date column headings are left aligned.
  • Number column heading are right align .
  • Default heading display in UPPERCASE .

      I am interested in hearing your feedback, so that I can improve my articles and learning resources for you.connect with us on facebooktwitter

Share

Did you enjoy reading this and found it useful? If so, please share it with your friends:

Merge statement

          In oracle 9i Release 2, Merge statement is introduced to select rows from one or more source for update or insertion into one or more tables .Merge statement have the ability to delete rows,as well as update and insert them So it is also known as "UPSERT"
  • Useful in data warehousing .
  • Increases performance and ease of use
Syntax:

MERGE INTO table_name table_alias
USING (table|view|sub_query) alias
ON (join condition)
WHEN MATCHED THEN
UPDATE SET
col1 = col_val1,
col2 = col2_val
WHEN NOT MATCHED THEN
INSERT (column_list)
VALUES (column_values);

Example :


MERGE INTO emp_new c
USING employees e
ON (c.employee_id = e.employee_id)
WHEN MATCHED THEN
UPDATE SET
c.first_name = e.first_name,
c.last_name = e.last_name,
c.department_id = e.department_id
WHEN NOT MATCHED THEN
INSERT VALUES(e.employee_id, e.first_name, e.last_name,
e.email, e.phone_number, e.hire_date, e.job_id,
e.salary, e.commission_pct, e.manager_id,
e.department_id);

NOTE:
Deletion were always done separately via the DELETE statement.

 I am interested in hearing your feedback, so that I can improve my articles and learning resources for you.connect with us on facebooktwitter

Share

Did you enjoy reading this and found it useful? If so, please share it with your friends: