Reputation: 15862
To get field names one would use the command:
select column_name from information_schema.columns where table_name='person';
My question is how would one also get the field types in a similar list?
Upvotes: 7
Views: 9772
Reputation: 63
al shema
SELECT table_name, column_name ,column_type FROM information_schema.columns WHERE table_schema = 'shema name'
Upvotes: 0
Reputation: 459
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';
Upvotes: 0
Reputation: 69342
SELECT column_name, column_type # or data_type FROM information_schema.columns WHERE table_name='person';
Upvotes: 16
Reputation: 9389
SELECT
column_name,
data_type
FROM information_schema.columns
WHERE table_name='person';
Upvotes: 0
Reputation: 212412
select column_name,
column_type
from information_schema.columns
where table_name='person';
Upvotes: 0