连接数据库
添加用户
就是在mysql.user
中的用户
1 2
| USE mysql; INSERT INTO user (`Host`, `User`, `Password`) VALUES('localhost', 'zoro', PASSWORD('password'));
|
数据库操作
1 2 3 4
| SHOW DATABASES; CREATE DATABASE `test`; DROP DATABASE `test`; DROP DATABASE IF EXISTS `test`;
|
数据表操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| SHOW TABLES; SHOW CREATE TABLE `user`; SHOW COLUMNS FROM `user`; DESC `user`;
CREATE TABLE `user`( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(20) ); DROP TABLE `user`; INSERT INTO `user` (name) VALUES ('Zoro'), ('Luffy');
UPDATE user SET name='Roronoa zoro' WHERE name='zoro';
DELETE FROM user WHERE id=3;
ALTER TABLE user ADD email VARCHAR(50); ALTER TABLE user DROP email; ALTER TABLE user MODIFY email VARCHAR(100); ALTER TABLE user CHANGE email Email VARCHAR(100); ALTER TABLE user ALTER email SET DEFAULT 'onepiece@qq.com'; ALTER TABLE user ALTER email DROP DEFAULT; ALTER TABLE user RENAME TO users;
|
查询操作
1 2 3 4 5 6
| SELECT id, name FROM user; SELECT * FROM user WHERE id=1;
SELECT id, name FROM user WHERE name LIKE '%Zo%';
SELECT id, name FROM user WHERE name REGEXP '^Zo.*'
|
连接
索引
视图
导入导出
1.如果本文帮到了您,不妨点一下右下角的
分享按钮.
2.您的鼓励是博主写作最大的动力,感谢您的分享和赞赏.