开发者

Recieving only the structure of the table using SQL and PHP and put into an Array

开发者 https://www.devze.com 2022-12-18 14:38 出处:网络
Is it possible to receive only the structure of the table even if its empty and put the field names in an array. If so which SQL command make开发者_运维百科s that possible.If you are using MySQL 5.0 o

Is it possible to receive only the structure of the table even if its empty and put the field names in an array. If so which SQL command make开发者_运维百科s that possible.


If you are using MySQL 5.0 or later, you can get the field names from the INFORMATION_SCHEMA.COLUMNS table.

Something like

SELECT COLUMN_NAME
FROM COLUMNS
WHERE TABLE_NAME = <table_name>

Here is a link to a list of tables in the INFORMATION_SCHEMA database.


In Oracle and MySQL, this SQL query will give you the details of the table, including columns and column types:

describe table_name

This may or may not work in other databases.


thanks for the link the awnser is for example table 'vraag'

SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'vraag'
0

精彩评论

暂无评论...
验证码 换一张
取 消