Mysql常用命令学习笔记

连接数据库mysql -uroot -p -P3306
查看数据库SHOW DATABASES;
创建数据库CREATE DATABASE DBname;
选择数据库USE DBname;
查看数据表SHOW TABLES;
创建数据表CREATE TABLE TBname(name VARCHAR(20),age TINYINT);
插入记录INSERT INTO TBname VALUES(‘Lee’,20);
查看数据表结构DESCRIBE TBname;SHOW COLUMNS FROM TBname;
查看数据表内容SELECT * FROM TBname;
删除数据表DROP TBname;

无符号位UNSIGNED
自动编号AUTO_INCREMENT
禁止为空NOT NULL
设置主键PRIMARY KEY
唯一约束UNIQUE KEY
默认约束ENUM(‘1′,’2′,’3’) DEFAULT ‘3’

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google photo

You are commenting using your Google account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s