To get the column name of a table we use sp_help with the name of the object or table name. sp_columns returns all the column names of the object.
Best AnswerSELECT owner, column_nameFROM all_tab_columnsWHERE table_name = 'YOUR_TABLE_HERE'ORDER BY owner, table_name; You may wnat to add "AND owner =..." as the above query will return all tables/views that have the table_name 'YOUR_TABLE_HERE'.
select table_name from all_tab_columns where column_name = 'PICK_COLUMN'; If you've got DBA privileges, you can try this command instead: select table_name from dba_tab_columns where column_name = 'PICK_COLUMN'; Now if you're like me, you may not even know what the column you're searching for is really named.
You can query the USER_TAB_COLUMNS table for table column metadata.
SELECT table_name, column_name, data_type, data_length
FROM USER_TAB_COLUMNS
WHERE table_name = 'MYTABLE'
In SQL Server...
SELECT [name] AS [Column Name]
FROM syscolumns
WHERE id = (SELECT id FROM sysobjects WHERE type = 'V' AND [Name] = 'Your table name')
Type = 'V' for views Type = 'U' for tables
You can do this:
describe EVENT_LOG
or
desc EVENT_LOG
Note: only applicable if you know the table name and specifically for Oracle.
For SQL Server 2008, we can use information_schema.columns for getting column information
SELECT *
FROM information_schema.columns
WHERE table_name = 'Table_Name'
ORDER BY ordinal_position
For SQLite I believe you can use something like the following:
PRAGMA table_info(table-name);
Explanation from sqlite.org:
This pragma returns one row for each column in the named table. Columns in the result set include the column name, data type, whether or not the column can be NULL, and the default value for the column. The "pk" column in the result set is zero for columns that are not part of the primary key, and is the index of the column in the primary key for columns that are part of the primary key.
See also: Sqlite.org Pragma Table Info
That information is stored in the ALL_TAB_COLUMNS
system table:
SQL> select column_name from all_tab_columns where table_name = 'DUAL';
DUMMY
Or you could DESCRIBE
the table if you are using SQL*PLUS:
SQL> desc dual
Name Null? Type
----------------------------------------------------- -------- ---------------------- -------------
DUMMY VARCHAR2(1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With