Day 68 – SQL DESC Keyword
SQL DESC keyword is short for “DESCRIBE”, and it is used to display the structure or schema of a table in a database. The DESC keyword can be used to retrieve information about the columns in a table, including their names, data types, and any constraints that are defined on them.
The basic syntax for using the DESC keyword is as follows:
table_name is the name of the table whose structure will be described.
For example, to describe the structure of a table named “Customers”, the SQL statement would be:
This would display information about the columns in the “Customers” table, including their names, data types, and any constraints that are defined on them.
The output of the DESC command will vary depending on the database management system (DBMS) being used. Some DBMSs may display additional information, such as the default values or indexes that are defined on the columns.
It’s important to note that the DESC command is not part of the SQL standard, and it may not be supported by all database management systems. In some cases, the equivalent command may be “SHOW COLUMNS FROM table_name” or “SHOW FIELDS FROM table_name”.