Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to SELECT Column, * FROM TABLE in Oracle?

Tags:

sql

oracle

I am creating a lot of scripts, and sometimes to check that the tables are being updated as I need, I write on the fly several SELECT statements.

In SQL SERVER you can write something like:

SELECT Column1, *
FROM MY_TABLE

This is useful for visibility reasons, however that doesn't seem to work in ORACLE and I don't know how to achieve it, other than writing down all the Column Names manually.

How can you do this in oracle?

I know we shouldn't include a query like this in our production scripts, etc. I am just trying to use it on the fly while I am running my scripts in development. At different points I'm more interested to see the information of certain columns, in relation to the other ones, but I still want to see all the columns.

like image 540
Dzyann Avatar asked Jan 15 '15 14:01

Dzyann


People also ask

What is SELECT * from table in Oracle?

In short, it is used to convert a collection or pipelined function into a table that can be queried by a SELECT statement. Typically, the collection must be of a datatype that is defined at the database level (i.e. a datatype that was created by a create or replace type ... statement).

What is SELECT * from table?

An asterisk (" * ") can be used to specify that the query should return all columns of the queried tables. SELECT is the most complex statement in SQL, with optional keywords and clauses that include: The FROM clause, which indicates the table(s) to retrieve data from.

How do I SELECT a specific column in Oracle?

The Oracle SELECT clause:After the Oracle SELECT keyword, specify the names of the columns that you would like to retrieve, separated by comma (,). You can specify as many columns as you want; you can even specify the same column more than once. The columns appear in the order selected.

Is SELECT * slower than SELECT column?

For your question just use SELECT *. If you need all the columns there's no performance difference. Save this answer.


2 Answers

SELECT Column1, MY_TABLE.*
FROM MY_TABLE

Or if you give the table an alias:

SELECT Column1, T.*
FROM MY_TABLE T
like image 82
Kim Berg Hansen Avatar answered Oct 26 '22 20:10

Kim Berg Hansen


Use an alias:

SELECT Column1, t.*
FROM MY_TABLE t;
like image 29
Gordon Linoff Avatar answered Oct 26 '22 21:10

Gordon Linoff