作為一個菜雞中的戰(zhàn)斗機不努力怎么行呢。。。。。。。。。。。。。。。
好吧。。還是 ?玩心比較重。。我輸了
mysql 命令:
顯示 所有數(shù)據(jù)庫 : show databases; (注意以下 “;” 必加)

創(chuàng)建數(shù)據(jù)庫: ?create database dbName(庫名);
以上語句創(chuàng)建 數(shù)據(jù)庫 沒有添加 編碼格式 utf-8 導(dǎo)致 插入數(shù)據(jù)時會報:
Incorrect string value: '\xE6\x88\x91\xE6\x98\xAF...' for column 'uname' at row 1
這樣的錯誤;(額。。 寫在小本本上)
so ?那就在創(chuàng)建 庫的時候也把 編碼格式加上吧 :
create database mytestsql default character set utf8 collate?
utf8_bin; ?
(ps: utf8_bin 支持事務(wù);utf8mb4_bin 支持事務(wù)+表情; utf8_general_ci 不支持事務(wù);utf8mb4_general_ci 不支持事務(wù) +支持表情;? )
進入數(shù)據(jù)庫: use dbName(要進入的庫名);

進入庫后顯示庫內(nèi)所有表:show tables;

創(chuàng)建 user 表:create table user
(id int(11) primary key auto_increment,
uname varchar(255),
nick_name varchar(255),
birthday datetime,
gender int,
age int,
introduction varchar(255));
修改表名:alter table user rename to userb;
查詢表里所有列: desc tabName(表名);

添加列:alter table 表名 add column 列名 varchar(30);
刪除列:alter table 表名 drop column 列名;
修改列名MySQL: alter table 表名 change 列名 ?新列名 int
修改列名Oracle:lter table 表名 rename column 列名 to 新列名 int;
修改列屬性:alter table 表名 modify 列名 varchar(22);
插入一條數(shù)據(jù):
insert into user values(null, '名字呀~', '清風(fēng)滿樓', now(), 1, 18, '老子永遠 18 ');?

小伙砸。。要注意 列名與 寫入值 相對應(yīng)。
查詢所有數(shù)據(jù):
select * from user;

根據(jù)條件查詢數(shù)據(jù):
select * from user where ?id = 1;

更新數(shù)據(jù):
update user set uname = '改啥名' where id = 2;

有男要有女么。。。(改多列)
update user set uname = '妹汁', introduction = '美美噠' where id = 3;

刪除數(shù)據(jù)( 警告: 萬不得已, 千萬不要選擇 “跑路” 這條路)
DELETE FROM tbl_name WHERE 要刪除記錄的條件
WHERE 一個不慎就得 跑路, ?謹慎, 謹慎, 謹慎
例:
delete from user where id = 3;
清空整個表:
delete from user;
刪除表
DROP TABLE?user(表名);
或者是
DROP TABLE IF EXISTS user(表名);
注意! 注意! 跑路時間到!
drop database mytestsql(數(shù)據(jù)庫名>);
結(jié)束,可以跑路了。。