开发者

How to query the columns of a table when INFORMATION_SCHEMA gives acces denied?

开发者 https://www.devze.com 2022-12-28 11:12 出处:网络
What I am trying to do is get all the columns of a table (the table can be emp开发者_JS百科ty) Example of what I did before:

What I am trying to do is get all the columns of a table (the table can be emp开发者_JS百科ty)

Example of what I did before:

SELECT COLUMN_NAME 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE table_name = 'aTable' 
  AND table_schema = 'theDatabase'

it works perfectly on localhost however on my provider it gives:

#1142 - SELECT command denied to user 'username'@'localhost' for table 'COLUMNS'

Is there an alternative that doesn't use the INFORMATION_SCHEMA??


It doesn't give you as much information as the information schema, but if all you need are the names of columns, you can use:

DESCRIBE `theDatabase`.`aTable`
0

精彩评论

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