Home > Enterprise >  SQL query - I don't know all identifiers
SQL query - I don't know all identifiers

Time:01-12

Is there a way, where I can see every parameter or identifier I can query from my database? Not the contents but the "column names"

Something like

SELECT * FROM myDb AS String

CodePudding user response:

To simply get the column names and types of a table.
You could SHOW them.

SHOW COLUMNS FROM myTable;

But if you want to know the column names of your table, and only a bit of data from it (to see what it looks like).

Then use LIMIT to get only a few records.

SELECT * 
FROM myTable
LIMIT 3

It's fast and easy.

But you can also just see the columns without data if you use a criteria that's false.

SELECT * 
FROM myTable
WHERE 0=1

CodePudding user response:

You can also use:

show create table table_name;

but as "LukStorms" mentioned, the below statement shows you the data in table format and in a pretier way

show columns from table_name;

CodePudding user response:

You can use INFORMATION_SCHEMA.COLUMNS to retrieve all columns name

select column_name from INFORMATION_SCHEMA.COLUMNS where Table_Name='Your_Table'

  •  Tags:  
  • Related