DESC
DESC is a SQL command used to describe the structure of a database table. It provides a listing of all columns, the datatype of each column, and any additional information related to those columns within a specified table.
Example
Output
Explanation
The DESC
statement is used in MySQL to describe the structure of a specified table in the database. In this example, DESC myTable;
shows the columns (Field), data types (Type), whether NULL values are allowed (Null), the Key status of each column, the Default values, and any Extra information for each column in the myTable
within myDatabase
.
Example
Output
Explanation
DESC
is a command in PostgreSQL that provides the description of a table. It lists all columns, their data types, whether they can be null, and their default values, if any. In the above example, DESC employees;
is providing the description of the employees
table.
Example
Output
Explanation
The command showcases the use of DESC keyword in SQL which sorts the results in a descending order as per the column mentioned after ORDER BY clause i.e., CustomerID in this scenario. After execution, the Customers table is displayed with records arranged in descending order of CustomerID.
Example
Output
Explanation
The DESC
command in SQL is used to display the structure of a table. It provides a detailed view of each attribute (column) in the table, including the type of data associated with the attribute and whether the attribute allows null values or not.
This example shows the structure of the employees
table.
Example
Output
Explanation
The SQL DESC command is used in the ORDER BY clause to sort the data in descending order. The example demonstrated sorts the column ‘SALARY’ in descending order. In the output, you can see that the employee with the highest salary is listed first.