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
Release: 2023-09-03 16:21:03
forward
1039 people have browsed it

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;
Copy after login

Example

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

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
   ------------------------------);
Copy after login

Example

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

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template