標籤:mysql
1.資料庫(此處"pikachu“為資料庫名稱)
SHOW DATABASES; ##查看資料庫
USE pikachu; ##切換到資料庫
CREATE DATABASE pikachu; #建立資料庫
DROP DATABASE pikachu; #刪除資料庫
2.表(此處"student"為表名稱)
SHOW TABLES; #查看錶
CREATE TABLE student (name VARCHAR(20), sex CHAR(1)); ##建立表
DROP TABLE student ; ##從資料庫中刪除表
DESCRIBE student; ##查看錶結構
INSERT INTO student VALUES (‘lmy‘,‘F‘); ## 向表中添加資訊
DELETE FROM student WHERE attribute = value; ##從表中刪除資訊
SELECT * FROM student; ##查看錶中所有資訊
UPDATE student SET attribute=value2 WHERE attribute > =value1; ##修改表中資訊,將表中的value1改為value2
ALTER TABLE student add age varchar(4); ##向表中添加"age"欄位
ALTER TABLE student DROP age; ##從表中刪除欄位
3.查詢
SELECT * FROM pikachu.student; ##查詢pikachu資料庫下的student表
SELECT name FROM student WHERE age=‘20‘ and sex=‘M‘; ##查詢student表中年齡為20,性別男的人的姓名
4.重新整理資料庫資訊
FLUSH PRIVILEGES;
5.mysql root使用者密碼忘記解決辦法
本文出自 “11849650” 部落格,謝絕轉載!
複習篇--mysql 基礎語句