To get field names one would use the command:
select column_name from information_schema.columns where table_name='person';
开发者_JAVA百科
My question is how would one also get the field types in a similar list?
SELECT column_name, column_type # or data_type FROM information_schema.columns WHERE table_name='person';
Schema Info
select column_name,
column_type
from information_schema.columns
where table_name='person';
SELECT
column_name,
data_type
FROM information_schema.columns
WHERE table_name='person';
If we want both column_name & column_type or Data Type: select column_name, column_type from information_schema.columns where table_name='personal_info';
If we want only column_name:
select column_name from information_schema.columns where table_name='personal_info';
If we want only column_type: select column_type from information_schema.columns where table_name='personal_info';
al shema
SELECT table_name, column_name ,column_type FROM information_schema.columns WHERE table_schema = 'shema name'
精彩评论