MySql笔记

听闻少年二字,当与平庸相斥。这篇文章主要讲述MySql笔记相关的知识,希望能为你提供帮助。
创建用户
create user dapai@localhost identified by 123;
赋予超级用户
grant all privileges on *.* to dapai@localhost with grant option;
修改密MA
alter user dapai@localhost identified by 123;
删除用户
drop user dapai@localhost;  


创建数据库
create DATABASE XXXXX
删除数据库
drop DATABASE XXXXX
选择数据库(进行操作)
use XXXXX


插入数据表
CREATE TABLE runoob_tbl(
  -> runoob_id INT NOT NULL AUTO_INCREMENT,
  -> runoob_title VARCHAR(100) NOT NULL,
  -> runoob_author VARCHAR(40) NOT NULL,
  -> submission_date DATE,
【MySql笔记】  -> PRIMARY KEY ( runoob_id )
  -> )ENGINE=InnoDB DEFAULT CHARSET=utf8;


插入数据
INSERT INTO runoob_tbl  
    -> (runoob_title, runoob_author, submission_date)
    -> VALUES
    -> ("学习 php", "菜鸟教程", NOW());


查询数据
SELECT * from runoob_tbl WHERE runoob_author=菜鸟教程;


更新某条数据
UPDATE runoob_tbl   SET   runoob_title=学习   WHERE runoob_id=3; (runoob_id唯一标识)


删除某条数据
DELETE FROM runoob_tbl WHERE runoob_id=3; (runoob_id唯一标识)


查询某条类似数据(like)
SELECT * from runoob_tbl   WHERE runoob_author   LIKE   %COM; (找到比如A.COM)


查找name字段中包含mar字符串的所有数据(正则表达式)
mysql> SELECT name FROM person_tbl WHERE name REGEXP mar;





    推荐阅读