![]() ![]() See the queries below with output simultaneously:Īs you can see both outputs are identical with DESCRIBE and EXPLAIN Table commands as well. We can say that both are synonyms to each other and any of them in SQL server can be applied to retrieve information about a particular table. The EXPLAIN Table and DESCRIBE Table commands are similar in working and generates the same result rows. Let us take the table Customer with fields: CustomerID, CustomerName, Credit_Limit and City having their respective data types and other attributes. Example #3Įxample with DESCRIBE TABLE command Vs EXPLAIN TABLE command. Similarly, for in Emp_ID row you can see the auto_increment value in the Extra column which is the attribute added in table making time as mentioned in the above query. Next, we will query using DESC TABLE command to get the details of the table by the statement below:Īs you can view while creating we have added default value for the Emp_Salary column and therefore when described the result shows DEFAULT as 0 in Emp_Salary row. Now, displaying the contents of table Emp_Data: Example #2Īssume that we are having a table named Emp_Data present in our database created as follows:Ĭode: CREATE TABLE Emp_Data(Emp_ID INT AUTO_INCREMENT PRIMARY KEY, Emp_Name VARCHAR(255), Emp_Salary INT NOT NULL DEFAULT 0) Īfter completing the structure of table let us fill in some records as below:Ĭode: INSERT INTO `emp_data`(`Emp_ID`, `Emp_Name`, `Emp_Salary`) VALUES Note that the YES in NULL column says that the value for that specific column of table can be NULL and NO denotes we cannot place or insert NULL values. The data type values with its length and NULL attribute with YES/NO values for its presence and PRIMARY key are also provided in the structure of the table. Now, let us apply simply the DESCRIBE TABLE query written as below:Īs you can see in the output above that the column names of the table Books with Type, NULL attribute, Key, Default values and even Extra attribute are described by the DESCRIBE TABLE statement. The contents of the table can be shown as below: We have a table named Books in our database with fields as BookID, BookName, Language, Price and each having different data type defined at the time of table creation. Suppose, we have taken a table as demo to use the DESCRIBE. Simple Example using DESCRIBE TABLE command. ![]() Given below are the examples of SQL DESCRIBE TABLE: Thus, the SQL DESCRIBE TABLE is beneficial for fetching out details about the current table present in the database.The SQL DESCRIBE TABLE query will make us to know about the organization of table that consists of name of table column with data type values such as VARCHAR, CHAR, INT, FLOAT, TIME, DATE, NUMBER or any XML type, used for the respective fields in the table, also it displays column having NULL or NOT NULL database objects that says if the column do include null values or not.When we execute DESCRIBE TABLE command in our database we will be able to view the structure of the table in a describe tab but not on the console tab of the system software.Therefore, using DESCRIBE TABLE in SQL it will tell you either about the columns present in that specific table or its current values type and also the default values for a table’s stage properties.These both statements when executed will provide information about all table columns. DESCRIBE can be said as a synonym for the command EXPLAIN TABLE.Also, it should be remembered that the query with criteria TYPE = STAGE cannot be applied for views as views do not contain stage properties.But by default the server uses TYPE = COLUMNS, if the TYPE keyword not provided in the query.The TYPE = (STAGE | COLUMNS) term defines whether to show the table columns or the stage properties which comprises of their default and current values for the table.We can enclose the whole string using double quotes which are case-sensitive when the identifier includes spaces or special characters. We can also monitor another syntax type in advance level as follows: TABLE defines an identifier for the particular table mentioned to describe it. ViewName also denotes the name of the view created for the table and we wish to describe the view structure.The TableName denotes the name of the table in the database for which we want to see the structure. ![]() The terms mentioned above are described below: ![]() Let us elaborate the elementary syntax to show the structure of DESCRIBE TABLE command in SQL server: DESCRIBE | DESC Hadoop, Data Science, Statistics & others Syntax of SQL DESCRIBE TABLE ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |