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

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

WBOY
Release: 2016-06-01 13:16:24
Original
1127 people have browsed it

创建数据库:

<strong>CREATE DATABASE stefan;</strong>
Copy after login

删除数据库:

<strong>DROP DATABASE stefan;</strong>
Copy after login

重命名数据库:

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

已经不再使用的方法:

<strong>RENAME DATABASE stefan TO LCDB;</strong>
Copy after login

创建表格语法:

<strong>CREATE TABLE 表名称(列名称1 数据类型,列名称2 数据类型,列名称3 数据类型,....)</strong>
Copy after login

查看一个表格结构:

<strong>DESCRIBE Persons;</strong>
Copy after login

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

语法:

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

<strong>ALTER TABLE table_nameADD column_name datatype</strong>
Copy after login

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

<strong>ALTER TABLE table_name DROP COLUMN column_name</strong>
Copy after login

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

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

<strong>ALTER TABLE table_nameALTER COLUMN column_name datatype</strong>
Copy after login

Related labels:
source:php.cn
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