Skip to content

Instantly share code, notes, and snippets.

@Xifeng2009
Created January 8, 2019 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xifeng2009/a695ae4a8c4cda76d392639393cb06a7 to your computer and use it in GitHub Desktop.
Save Xifeng2009/a695ae4a8c4cda76d392639393cb06a7 to your computer and use it in GitHub Desktop.
##大写: 变量
# 查询
mysql> select * from TABLE where id=1;
# 插入
mysql> insert into TABLE (姓名, 性别, 年龄) values ('张三', '男', 33);
# 更新
mysql> update TABLE set title='母猪的产后护理' where id=3;
# 删除
mysql> delete from TABNLE where id=1;
# 子句: LIKE
mysql> SELECT * from runoob_tbl WHERE runoob_author LIKE '%COM';
# 子句: UNION
mysql>
SELECT country FROM Websites
UNION
SELECT country FROM apps
ORDER BY country;
# 子句: JOIN
mysql> select a.id, a.name from TABLE1 a inner join TABLE2 b on a.name=b.name;
mysql> SELECT a.id, a.author, b.count FROM tbl a LEFT JOIN tbl b ON a.author = b.author;
mysql> SELECT a.id, a.author, b.count FROM tbl a RIGHT JOIN tbl b ON a.author = b.author;
# 连接
[root@host]# mysql -u root -p
# 创建数据库
1.
mysql> create DATABASE NEWDB;
2.
[root@host]# mysqladmin -u root -p create RUNOOB
# 删除数据库
1.
mysql> drop database RUNOOB;
2.
[root@host]# mysqladmin -u root -p drop RUNOOB
# 选择数据库
mysql> use NEWDB;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment