먼저 데모 테이블을 생성해 보겠습니다.
mysql> create table excludeCertainColumnsDemo -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(100), -> StudentAge int, -> StudentMarks int, -> StudentAddress varchar(200) -> ); Query OK, 0 rows affected (0.50 sec)
이제 desc 명령을 사용하여 테이블의 설명을 확인할 수 있습니다. 쿼리는 다음과 같습니다 -
mysql> desc excludeCertainColumnsDemo;
다음은 출력입니다.
+----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentName | varchar(100) | YES | | NULL | | | StudentAge | int(11) | YES | | NULL | | | StudentMarks | int(11) | YES | | NULL | | | StudentAddress | varchar(200) | YES | | NULL | | +----------------+--------------+------+-----+---------+----------------+ 5 rows in set (0.01 sec)
다음은 SHOW COLUMNS에서 특정 열을 제외하는 쿼리입니다. 'StudentAge' 및 'StudentMarks' 열을 제외해야 합니다. 쿼리는 다음과 같습니다 -
mysql> SHOW COLUMNS FROM excludeCertainColumnsDemo WHERE Field NOT IN ('StudentAge', 'StudentMarks');
다음은 출력입니다.
+----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | StudentId | int(11) | NO | PRI | NULL | auto_increment | | StudentName | varchar(100) | YES | | NULL | | | StudentAddress | varchar(200) | YES | | NULL | | +----------------+--------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)