![]() You can verify the above created table using the DESC statement too. Mysql> CREATE TABLE sample LIKE Employee Exampleįollowing query create a new table sample same as the table Employee Where, table_name is the name of the table you need to create and old_table_name is the name of the table from which you need to create the new one. You can also create a table using the existing table (with same definition), following is the syntax to do so −ĬREATE TABLE table_name Mysql> CREATE TABLE Test(Name VARCHAR(255)) 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. Mysql> CREATE TABLE Employee(Name VARCHAR(255)) ĮRROR 1050 (42S01): Table 'employee' already exists If you try to create a table with an existing name an error will be generated − The SHOW TABLES statements gives you the list of tables in the current database, if the creation is successful, you can see the name of the above created table in it. ![]() Exampleįollowing query creates a table with name Employee − Where, table_name is the name of the table you need to create, column1, column2, column3, …….… columnN are the names of the columns and datatype is the name of the datatypes of the respective columns. Syntaxįollowing is the syntax to create a table in MySQL − Here, you need to specify the name of the table and, definition (name and datatype) of each column. The syntax is the same for Oracle, SQL Server, MySQL, and PostgreSQL. The CREATE TABLE statement is used to create tables in MYSQL database. This example uses the Create Table as Select to create a table from another table, but no data is added to the new table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |