
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Generate Table DDL via a Query on MySQL and SQL Server
The DDL stands for Data Definition Language. To generate the table DDL via query, you can use show create command.
The syntax is as follows
SHOW CREATE TABLE yourTableName;
The above syntax is MySQL specific. Suppose, we have a table with the name ‘DDLOfTableStudent’.
First, create a table with the name ‘DDLOfTableStudent’. The query to create a table is as follows
mysql> create table DDLOfTableStudent -> ( -> StudentId int, -> StudentFirstName varchar(100), -> StudentLastName varchar(100), -> StudentAddress varchar(200), -> StudentAge int, -> StudentMarks int -> ); Query OK, 0 rows affected (0.84 sec)
Use the above syntax to know the DDL of a table. The query is as follows
mysql> SHOW CREATE TABLE DDLOfTableStudent;
The following is the output displaying the DDL
+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | DDLOfTableStudent | CREATE TABLE `ddloftablestudent` (`StudentId` int(11) DEFAULT NULL,`StudentFirstName` varchar(100) DEFAULT NULL,`StudentLastName` varchar(100) DEFAULT NULL,`StudentAddress` varchar(200) DEFAULT NULL,`StudentAge` int(11) DEFAULT NULL,`StudentMarks` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | +-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
Advertisements