![]() You can verify the above created table using the DESC statement too. ![]() Mysql> CREATE TABLE sample LIKE Employee mysql> create table OldTableDemo -> ( -> UserId int NOT. The query to create first table is as follows. create table yourTableName ( select from yourTableName1 ) UNION ( select from yourTableName2 ) To understand the above syntax, let us create a table. Exampleįollowing query create a new table sample same as the table Employee The following is the syntax to merge two tables using MySQL union. 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 CREATE TABLE statement is used to create tables in MYSQL database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |