标签:mysql
连接mysql
mysql -hlocalhost -uroot -p
查看当前数据库
SHOW DATABASES;
创建数据库shop
CREATE DATABASE shop
删除数据库shop
DROP DATABASE shop
选择(打开)数据库shop
USE shop
查看当前操作数据库里面的所有表
SHOW TABLES
查看某一张表的结构(例:user表)
DESC user;
创建一张user表
CREATE TABLE user( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, username CHAR(20) NOT NULL, password CHAR(32) NOT NULL, UNIQUE KEY username(username) )ENGINE = INNODB DEFAULT CHARSET =UTF8;
删除一张表
DROP TABLE user;
向表里面插入一条数据
INSERT INTO user(id,username,password) values(null,‘wangzherongyao‘,20);
更新一条数据
UPDATE user set password = ‘mima123456‘ where username=‘wangzherongyao‘;
删除一条数据
DELETE FROM user where id=1;
查询语句
SELECT * FROM user where id=1;
本文出自 “YBT-PHP” 博客,谢绝转载!
标签:mysql
原文地址:http://ybtphp.blog.51cto.com/13257319/1969817