Say I've got a table known as myTable. What's the SQL command to come back all the area names of the table? If the reply is database specific i quickly need SQL Server at this time but would want to consider seeing the answer for other database systems too.

MySQL 3 and 4 (and 5):

desc tablename

that is an alias for

show fields from tablename

MSSQL (from 2000) and MySQL 5:

select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS 
where TABLE_NAME = 'tablename'

Finishing the solution: Like people below have stated, in MSSQL you may also make use of the saved procedure sp_help

exec sp_help 'tablename'

SQL-92 standard defines INFORMATION_SCHEMA which conforming rdbms's like MS SQL Server support. The next works best for MS SQL Server 2000/2005/2008 and MySql 5 and above

select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'myTable'

MS SQl Server Specific:

exec sp_help 'myTable'

This solution returns several result sets within the information you would like, while the previous provides you with exactly what you would like.

Also only for completeness you are able to query the sys tables directly. This isn't suggested because the schema can alter between versions of SQL Server and knowledge_SCHEMA is really a layer of abstraction above these tables. But here you go anyway for SQL Server 2000

select [name] from dbo.syscolumns where id = object_id(N'[dbo].[myTable]')

You should use the provided system sights to get this done:

eg

select * from INFORMATION_SCHEMA.COLUMNS
where table_name = '[table name]'

alternatively, you should use the machine proc sp_help

eg

sp_help '[table name]'

For individuals searching for a solution in Oracle:

SELECT column_name FROM user_tab_columns WHERE table_name = 'TABLENAME'

PostgreSQL knows the

select column_name from information_schema.columns where table_name = 'myTable'

syntax. If you are employed in the psql spend, you may also use

\d myTable

for any description (posts, as well as their datatypes and constraints)

Should you simply want the column names, then

select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'tablename'

On MS SQL Server, for additional info on the table like the kinds of the posts, use

sp_help 'tablename'

This is MySQL Specific:

show fields from [tablename];

this does not just show the table names it pulls out all of the information on the fields.

In Sybase SQL Anywhere, the posts and table information are saved individually, so you'll need a join:

select c.column_name from systabcol c 
       key join systab t on t.table_id=c.table_id 
       where t.table_name='tablename'

As well as for IBM DB2 (will make sure this on Monday to be certain...)

Choose TABNAME,COLNAME from SYSCAT.Posts where TABNAME='MYTABLE'

MySQL is identical:

select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'tablename'

MySQL

describe tablename

Only for completeness, since MySQL and Postgres happen to be pointed out: With SQLite, use "pragma table_info()"

sqlite> pragma table_info('table_name');
cid         name        type        notnull     dflt_value  pk        
----------  ----------  ----------  ----------  ----------  ----------
0           id          integer     99                      1         
1           name                    0                       0