Renaming columns - sql, PL-SQL Programming

Renaming Columns - SQL

SQL has no direct counterpart of RENAME. To derive the table on the right in Figure 4.4 from the table on the left, Tutorial D has IS_CALLED RENAME ( StudentId AS Sid ).

1010_Renaming Columns - SQL.png

                                                    Figure: Tables differing only in a column name

It shows how the same effect can be achieved in SQL. Note that the SELECT clause has to include all the columns that are not subject to renaming, as well as those that are.

Example: Renaming a column

SELECT StudentId AS Sid, Name

FROM IS_CALLED

Explanation

  • Each element of a SELECT clause is an expression of arbitrary complexity that can reference one or more columns of the SELECT clause's input table. Note that the expression is not required to reference any columns: it might be just a literal, for example.
  • If the expression consists of just a column reference, then the name of the referenced column is the name of the corresponding column in the result.
  • If the expression is followed by the key word AS, then the resulting column has the column name given after that key word.

SQL allows the result to have two or more columns of the same name. For example, if we replace Sid by Name in Example, we still have a valid SQL SELECT expression.

Posted Date: 1/18/2013 5:07:25 AM | Location : United States







Related Discussions:- Renaming columns - sql, Assignment Help, Ask Question on Renaming columns - sql, Get Answer, Expert's Help, Renaming columns - sql Discussions

Write discussion on Renaming columns - sql
Your posts are moderated
Related Questions
First Step at defining type SID in SQL CREATE TYPE SID AS ( C VARCHAR(5) ) ; Explanation: TYPE SID announces that a type named SID is being defined to the syst

LIKE Operator You use the LIKE operator to compare the character value to a pattern. The Case is significant. LIKE returns the Boolean value TRUE when the character patterns mat

Package Specification The package specifications contain the public declarations. The scopes of these declarations are local to your database representation and global to the

ROWNUM The ROWNUM returns a number representing the order in which a row was selected from the table. The first row selected has a ROWNUM of 1; the second row has a ROWNUM of

SQL Operators The PL/SQL uses all the SQL set, comparison, and row operators in the SQL statements. This part briefly describes some of these operators.  1. Comparison Opera

Keyword and Parameter Description: table_reference: This specifies a table or view that should be accessible when you execute the DELETE statement, and for that you must

Keyword & Parameter Description: PRAGMA: These keywords signify that the statement is a pragma (i.e. compiler directive). The Pragmas are processed at the compile time, n

Transactions in SQL BEGIN TRANSACTION, COMMIT, and ROLLBACK, SQL has the same syntax except for START in place of BEGIN. However, START TRANSACTION is used only for outermost

Pl/sql Conditional Control: IF statements Frequently, it is necessary to take the alternative actions depending on the circumstances. The IF statement execute a series of statem

Authorize and fetch data from Instagram Project Description: Incorporate Instagram feed on mobile site platform: c#, ms sql, jquerymobile, jquery Web admin Author