![]() If the CREATE TABLE statement has an IF NOT EXISTS clause in it, then the result of the SHOW CREATE TABLE Statement of the respective database also contains the IF NOT EXISTS clause. Query OK, 0 rows affected, 1 warning (0.10 sec) Mysql> CREATE TABLE IF NOT EXISTS Employee(ID int) If you use the IF NOT EXISTS clause along with the CREATE statement as shown below a new table will be created and if a table with the given name, already exists the query will be ignored. If you try to create a table with an existing name an error will be generated −ĮRROR 1050 (42S01): Table 'employee' already exists | Employee | CREATE TABLE `employee` ( `ID` int NOT NULL, `Name` varchar(255) DEFAULT NULL, `Salary` int NOT NULL, `Location` varchar(255) DEFAULT NULL, `Address` varchar(50) DEFAULT NULL, `Phone` int DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `con` (`Phone`), CONSTRAINT `MyPrimaryKey` FOREIGN KEY (`ID`) REFERENCES `test` (`ID`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | The following query displays the query used to create the database − Suppose we have created a database as shown below − ![]() Where, table_name is the name of the table. The MySQL SHOW commands permit showing off the structure, fields, indexes, and functions created or stored procedures of the MySQL server, which may be necessary to. Syntaxįollowing is the syntax of the SHOW CREATE TABLE statement − This MySQL SHOW command helps provide various transactional, datetime, and output statuses of all the MySQL statement queries on the MySQL server, which we need to keep records of. This displays the create statements along with the clauses. ![]() This query shows/displays the statement used to create the specified table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |