Home  >  Article  >  Database  >  MySQL超级简明基本操作攻略,给自己看(一)_MySQL

MySQL超级简明基本操作攻略,给自己看(一)_MySQL

WBOY
WBOYOriginal
2016-06-01 13:02:341149browse

系统:Ubuntu 14.04 LTS

安装:

apt-get install mysql
//安装数据库
apt-get install mysql-workbench
//安装图形界面
使用:

启动时:mysql -h [地址] -p [端口] -u[用户名] -p[密码]

进入后会是这样:\

mysql >是输入命令的地方,退出可以用exit

在mysql中,命令一般都需要加分号。

数据库操作:

create database 数据库名;   创建
show databases;   查看
drop databases;  删除
use 数据库名;     使用当前数据库
表的操作:
show tables ;查看表
create table(列名 数据类型  额外参数,...) ; 建立表
常用额外参数:

NULL/NOT NULL

DEFAULT 默认值

AUTO_INCREMENT 自增

UNIQUE 唯一

PARMIRY KEY 主键

外键(这个和SQL Server用的不一样)

CONSTRAINT FOREIGN KEY(键名) REFERENCES(键名)

字符集(不设置有可能出现乱码)

CHARSET=UTF-8/.....

对表本身的操作就和标准的SQL语言一样了。

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