stuTab表名
顯示數(shù)據(jù)庫:show databases;
創(chuàng)建數(shù)據(jù)庫:create database if not exists studb
操作表:use studb
顯示表:show tables
創(chuàng)建表:create table if not exists stuTable (id int,name varchar(20),gender varchar(2))ENGINE='innoDB' default charset='utf8';
插入數(shù)據(jù):insert into stuTable (id,name,gender) values (1,'yangshaofeng','M
顯示信息:SELECT * FROM STUtABLE;
修改: update stuTable set name = 'zhangsan' where id=1;
刪除: delete from stuTable where id = 1;
查看表結(jié)構(gòu):show create table sstuTable;
表的重命名:rename table stuTable to newTable;
刪除表: drop table newTable;
刪除數(shù)據(jù)庫:drop database stu;
alter 增加字段 刪除一個字段 飛字段擴充長度
修改字段或者表的編碼 修改字段的名字
設(shè)置id可以自增: create table if not exists stuTable(id int not null auto_increment primary key, name varchar(2)not null) engine = 'innodb' default charset = 'utf8';
修改字段類型和名字:alter table stuTable change name name varchar(20) not null;
添加字段:alter table stuTable add(phone text);
根據(jù)id查找:select * from stuTable where id = 4;
指查找名字:select name from stuTable where phone ='125650'or phone = '120';
顯示個數(shù)根據(jù)條件:select count(name) from stuTable where phone = '125650' or phone = '120';
模糊查找:select count(name) from stuTable where name like 'gao%';
根據(jù)成績排序(升序):select score from scoretable order by score;
降序: select score from scoretable order by score desc;
最大數(shù):select max(score) from scoretable;
最高得分:select max(score) as '最高分' from scoretable; as是起別名的
最低分:select min(score) as '最低分' from scoretable;
平均分:select avg(score) as '平均分' from scoretable;
分數(shù)大于70并且排序:select score from scoretable where score >70 order by score;
limit從1開始取6條:select score from scoretable where score >70 order by score limit 1,6; (1是下標)
查找子字段:select score from scoreTable where stuId =(select id from stuTable where name = 'gaopeng 'limit 1,1);
數(shù)據(jù)庫
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來舟误,“玉大人葡秒,你說我怎么就攤上這事。” “怎么了眯牧?”我有些...
- 文/不壞的土叔 我叫張陵蹋岩,是天一觀的道長。 經(jīng)常有香客問我学少,道長剪个,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任版确,我火速辦了婚禮扣囊,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘绒疗。我一直安慰自己侵歇,他們只是感情好,可當我...
- 文/花漫 我一把揭開白布吓蘑。 她就那樣靜靜地躺著惕虑,像睡著了一般。 火紅的嫁衣襯著肌膚如雪士修。 梳的紋絲不亂的頭發(fā)上枷遂,一...
- 文/蒼蘭香墨 我猛地睜開眼雹锣,長吁一口氣:“原來是場噩夢啊……” “哼网沾!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起蕊爵,我...
- 正文 年R本政府宣布酸纲,位于F島的核電站,受9級特大地震影響瑟匆,放射性物質(zhì)發(fā)生泄漏福青。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一脓诡、第九天 我趴在偏房一處隱蔽的房頂上張望无午。 院中可真熱鬧,春花似錦祝谚、人聲如沸宪迟。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽次泽。三九已至,卻和暖如春席爽,著一層夾襖步出監(jiān)牢的瞬間意荤,已是汗流浹背。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- SQL語言基礎(chǔ) 本章握恳,我們將會重點探討SQL語言基礎(chǔ),學(xué)習(xí)用SQL進行數(shù)據(jù)庫的基本數(shù)據(jù)查詢操作捺僻。另外請注意本章的S...
- (一)Oracle數(shù)據(jù)庫 1.oracle中row_id理解 ORACLE的row_id是一個偽列,其個是為18個...
- mysql數(shù)據(jù)庫中 :database : 文件夾table : 數(shù)據(jù)表(數(shù)據(jù)文件) 進入mysqlmysql -...
- CREATE TABLE IF NOT EXISTS ecs_order_info (order_id mediu...
- //文章表 文章標題(title)乡洼、文章內(nèi)容(content)、文章點擊量(hits)匕坯、文章評論量(coms) c...