Home >Database >Mysql Tutorial >mysql学习之二:sql语句学习2_MySQL

mysql学习之二:sql语句学习2_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:16:251114browse

创建数据库:

<strong><code style="padding:0px; background-color:transparent; border:0px">CREATE DATABASE stefan;</code></strong>

删除数据库:

<strong><code style="padding:0px; background-color:transparent; border:0px">DROP DATABASE stefan;</code></strong>

重命名数据库:

重命名数据库没有直接的办法。

已经不再使用的方法:

<strong><code style="padding:0px; background-color:transparent; border:0px">RENAME DATABASE stefan TO LCDB;</code></strong>

创建表格语法:

<strong><code style="padding:0px; background-color:transparent; border:0px">CREATE TABLE 表名称(列名称1 数据类型,列名称2 数据类型,列名称3 数据类型,....)</code></strong>

查看一个表格结构:

<strong><code style="padding:0px; background-color:transparent; border:0px">DESCRIBE Persons;</code></strong>
  

ALTER TABLE 语句用于在已有的表中添加、修改或删除列。

语法:

如需在表中添加列,请使用下列语法:

<code style="padding:0px; background-color:transparent; border:0px"><strong>ALTER TABLE table_nameADD column_name datatype</strong></code>

要删除表中的列,请使用下列语法:

<code style="padding:0px; background-color:transparent; border:0px"><strong>ALTER TABLE table_name DROP COLUMN column_name</strong></code>

注释:某些数据库系统不允许这种在数据库表中删除列的方式 (DROP COLUMN column_name)。

要改变表中列的数据类型,请使用下列语法:

<code style="padding:0px; background-color:transparent; border:0px"><strong>ALTER TABLE table_nameALTER COLUMN column_name datatype</strong></code>
Statement:
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