当前位置: 首页 > news >正文

网站免费网站入口/广州seo运营

网站免费网站入口,广州seo运营,标书制作软件免费版,北京专业网站制作公司本文主要向大家介绍了MySQL数据库之MySQL CREATE TABLE 语句详解 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。Summary: in this tutorial, we will show you how to create new tables in a particular database using MySQL CREATE…

本文主要向大家介绍了MySQL数据库之MySQL CREATE TABLE 语句详解 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。

Summary: in this tutorial, we will show you how to create new tables in a particular database using MySQL CREATE TABLE statement.

MySQL CREATE TABLE syntax

In order to create a new table within a database, you use the MySQL CREATE TABLE statement. The CREATE TABLE statement is one of the most complex statement in MySQL.

The following illustrates the syntax of the CREATE TABLE statement in the simple form:

CREATE TABLE [IF NOT EXISTS] table_name(         column_list         ) engine=table_type

Let’s examine the syntax in greater detail:

First, you specify the name of table that you want to create after the CREATE TABLE keywords.  The table name must be unique within a database. The IF NOT EXISTS  is an optional part of the statement that allows you to check if the table you are creating already exists in the database. If this is the case, MySQL will ignore the whole statement and it will not create any new table. It is highly recommended that you to use IF NOT EXISTS in every CREATE TABLE statement for preventing from an error of creating a new table that already exists.

Second, you specify a list of columns for the table in the column_list section. Columns are separated by a comma ( ,).  We will show you how to define columns in more detail in the next section.

Third, you need to specify the storage engine for the table in the engine clause. You can use any storage engine such as InnoDB, MyISAM, HEAP, EXAMPLE, CSV, ARCHIVE, MERGE FEDERATED or NDBCLUSTER. If you don’t declare the storage engine explicitly, MySQL will use InnoDBby default.

InnoDB became the default storage engine since MySQL version 5.5. The InnoDB table type brings many benefits of relational database management system such as ACID transaction, referential integrity and crash recovery.  In the previous versions, MySQL used MyISAM as the default storage engine.

To define a column for the table in the CREATE TABLE statement, you use the following syntax:

column_name data_type[size] [NOT NULL|NULL] [DEFAULT value] [AUTO_INCREMENT]

The most important components of the syntax above are:

The column_name specifies the name of the column. Each column always associates with  a specific data type and the size e.g.,   VARCHAR(255).

The  NOT NULL or NULL indicates that the column accepts NULL value or not.

The DEFAULT value is used to specify the default value of the column.

The AUTO_INCREMENT indicates that the value of column is increased by one whenever a new row is inserted into the table. Each table has one and only one AUTO_INCREMENT column.

If you want to set particular columns of the table as the primary key, you use the following syntax:

PRIMARY KEY (col1,col2,...)

Example of MySQL CREATE TABLE statement

Let’s practice with an example of creating a new table named tasks in our sample database as follows:

You can use the CREATE TABLE statement to create the tasks table as follows:

CREATE TABLE IF NOT EXISTS tasks (   task_id int(11) NOT NULL AUTO_INCREMENT,   subject varchar(45) DEFAULT NULL,   start_date DATE DEFAULT NULL,   end_date DATE DEFAULT NULL,   description varchar(200) DEFAULT NULL,   PRIMARY KEY (task_id) ) ENGINE=InnoDB

In this tutorial, you have learned how to use MySQL CREATE TABLE to create a new tables within a database.

本文由职坐标整理并发布,希望对同学们学习MySQL有所帮助,更多内容请关注职坐标数据库MySQL数据库频道!

http://www.jmfq.cn/news/4865959.html

相关文章:

  • wordpress多域名模板/优化关键词排名外包
  • 爱站网关键词挖掘工具站长工具/谷歌关键词搜索排名
  • 做go kegg的在线网站/app推广方案模板
  • 南京网站制作报价/搜索引擎入口大全
  • 北京外包公司 网站开发/整合营销传播的方法包括
  • 企业网站开发课程/seo对网站优化
  • 第一个做电子商务的网站/域名批量查询
  • wordpress插件去除google/seo上海推广公司
  • 网站seo外包价格/seo搜索优化怎么做
  • 长沙微网站/seo常规优化
  • 网站正能量晚上下载直接进入/腾讯朋友圈广告代理
  • 千锋前端培训班/宁波seo公司排名
  • 公司做网站需要提供什么条件/谷歌浏览器2021最新版
  • 国外网页设计评论网站/什么叫seo优化
  • 网站服务种类/宁波seo网络推广咨询价格
  • 淄博哪家网络公司做网站好/汽车seo是什么意思
  • 建设一个购物网站/山东自助seo建站
  • 委托第三方建设网站应注意哪些/seo在线外链
  • 吉林省建设厅网站市政建设/免费手游推广平台
  • 全国做网站找哪家好/网址查询服务中心
  • 外贸网站建设soho/微信软文范例
  • 做阿里巴巴小企业网站/seo是如何优化
  • 网站首页线框图怎么做/爱站网关键词查询网站的工具
  • 顺德做网站的公司哪家好/软件开发培训机构去哪个学校
  • 做鸭子的网站/网页设计可以自学吗
  • 如何识别网站建设/东莞网站建设做网站
  • 济南网站建设公司熊掌号/收录情况
  • 贵州安顺网站建设/品牌推广软文案例
  • 如何做网站测试/百度大数据查询怎么用
  • 怎么建立免费个人网站/重庆森林电影