বর্তমান ডেটাবেসের নির্দিষ্ট টেবিলের সব কলামের নাম, টাইপ এবং মেটাডেটা দেখাতে information_schema.columns কোয়েরি করা হয়।
সিনট্যাক্স
SELECT column_name AS ALL_FIELDS FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'yourTableName'\G
table_schema = DATABASE()— বর্তমান ডেটাবেস।\G— ভার্টিক্যাল ফরম্যাটে আউটপুট (MySQL CLI-এ)।
টেবিল তৈরি
mysql> CREATE TABLE DemoTable1938 (
StudentId INT,
StudentName VARCHAR(20),
StudentAge INT,
StudentCountryName VARCHAR(20),
StudentMobileNumber BIGINT
);
কলাম তালিকা দেখানো
mysql> SELECT column_name AS ALL_FIELDS
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'DemoTable1938'\G
আউটপুট (ভার্টিক্যাল):
*************************** 1. row *************************** ALL_FIELDS: StudentId *************************** 2. row *************************** ALL_FIELDS: StudentName *************************** 3. row *************************** ALL_FIELDS: StudentAge *************************** 4. row *************************** ALL_FIELDS: StudentCountryName *************************** 5. row *************************** ALL_FIELDS: StudentMobileNumber 5 rows in set (0.00 sec)
আরও বিস্তারিত তথ্য পাওয়া
SELECT column_name, data_type, character_maximum_length,
is_nullable, column_default, column_key, extra
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'DemoTable1938';
বিকল্প: DESCRIBE / SHOW COLUMNS
DESC DemoTable1938; -- অথবা SHOW COLUMNS FROM DemoTable1938;
এগুলো কুইক চেকের জন্য ভালো, কিন্তু প্রোগ্রাম্যাটিক্যালি ব্যবহারে information_schema ফ্লেক্সিবল।
সকল টেবিলের কলাম একসাথে দেখানো
SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_schema = DATABASE() ORDER BY table_name, ordinal_position;