Home >Database >Mysql Tutorial >What is the MySQL CREATE command? How can we create database and table at the same time using this command?

What is the MySQL CREATE command? How can we create database and table at the same time using this command?

PHPz
PHPzforward
2023-09-03 16:21:031036browse

MySQL CREATE 命令是什么?我们怎样才能用这个命令同时创建数据库和表呢?

The CREATE command is a DDL command used to create a table or database. The syntax for creating tables and databases using the CREATE command is as follows -

Syntax for creating a database-

Create database database-name;

Example

mysql> Create database query;
Query OK, 1 row affected (0.04 sec)

In the above example, we created a file named " query" database.

Syntax for creating table -

Create table table-name(
   column-name1 datatype1,
   column-name2 datatype2,
   column-name3 datatype3,
   column-name4 datatype4
   ------------------------------);

Example

mysql> Create table Employee(Id INT, Name Varchar(20));
Query OK, 0 rows affected (0.19 sec)

In the above example, we have created a table named "Employee" which contains "Id" and "Name" two columns.

The above is the detailed content of What is the MySQL CREATE command? How can we create database and table at the same time using this command?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete