中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

一站式服務(wù)大廳百度seo規(guī)則

一站式服務(wù)大廳,百度seo規(guī)則,wordpress建站導(dǎo)航,武漢建設(shè)廳網(wǎng)站DDL語法 DDL(Data Definition Language) 數(shù)據(jù)定義語言,該語言部分包括以下內(nèi)容。 對(duì)數(shù)據(jù)庫的常用操作 對(duì)表結(jié)構(gòu)的常用操作 修改表結(jié)構(gòu) 對(duì)數(shù)據(jù)庫的常用操作 1: 查看當(dāng)前所有的數(shù)據(jù)庫 show databases; 2:創(chuàng)建數(shù)據(jù)庫 create dat…

DDL語法

DDL(Data Definition Language) 數(shù)據(jù)定義語言,該語言部分包括以下內(nèi)容。

  • 對(duì)數(shù)據(jù)庫的常用操作

  • 對(duì)表結(jié)構(gòu)的常用操作

  • 修改表結(jié)構(gòu)

對(duì)數(shù)據(jù)庫的常用操作

1: 查看當(dāng)前所有的數(shù)據(jù)庫

show databases;

2:創(chuàng)建數(shù)據(jù)庫

create database if not exists 數(shù)據(jù)庫名稱;

create database 數(shù)據(jù)庫名稱;

3:選擇使用哪一個(gè)數(shù)據(jù)庫

use 數(shù)據(jù)庫名稱;

4:刪除數(shù)據(jù)庫

drop database 數(shù)據(jù)庫名稱;

drop database if exists 數(shù)據(jù)庫名稱;

5:修改數(shù)據(jù)庫編碼

alter database school character set utf8;

對(duì)表結(jié)構(gòu)的常用操作-創(chuàng)建表

1:創(chuàng)建表格式

create table [if not exists] 表名(
? 字段1 類型[(寬度)] [約束條件] [comment '字段說明'],
? 字段2 類型[(寬度)] [約束條件] [comment '字段說明'],
? 字段3 類型[(寬度)] [約束條件] [comment '字段說明'],
)[表的一些設(shè)置];

創(chuàng)建表是構(gòu)建一張空表,指定這個(gè)表的名字,這個(gè)表有幾列,每一列叫什么名字,以及每一列存儲(chǔ)的數(shù)據(jù)類型。

2:數(shù)據(jù)類型

數(shù)據(jù)類型是指在創(chuàng)建表的時(shí)候?yàn)楸碇凶侄沃付〝?shù)據(jù)類型的,只有數(shù)據(jù)符合類型要求才能存儲(chǔ)起來,使用數(shù)據(jù)類型的原則是:夠用就行,盡量使用取值范圍小的,而不用大的,這樣可以更多的節(jié)省存儲(chǔ)空間。

  • 數(shù)值類型

  • 日期和時(shí)間類型

  • 字符串類型

3:數(shù)值類型

create table if not exists student(
? ?-- 無符號(hào) 沒有負(fù)數(shù)
?? sid int unsigned,
?? name varchar(20),
?? gender varchar(20),
?? age int,
?? birthday date,
?? address varchar(20)
);

  • 字符串類型

  • 日期類型

對(duì)表結(jié)構(gòu)的其它操作

1:查看當(dāng)前數(shù)據(jù)庫的所有表

show tables ;

2:查看數(shù)據(jù)表的創(chuàng)建語句

show create table 數(shù)據(jù)表名;

3:查看表結(jié)構(gòu)

desc 數(shù)據(jù)表名;

4:刪除表

drop table 數(shù)據(jù)表表名;

5:修改表結(jié)構(gòu)格式

語法格式

alter ?table 表名 add? 列名? 類型(長(zhǎng)度) 【約束】;

例子:

為student表添加一個(gè)字段為:系別dept類型為department
alter table student add column dept varchar(20);

6:修改列名和類型

語法格式

修改列名和表名,alter table 表名 change 舊列名 新列名 類型(長(zhǎng)度) [約束]

為student表中的dept字段更名為department varchar(30)

alter table student change dept department varchar(30);

7:修改表刪除列

語法格式:

alter table 表名 drop 列名;

例如:

# 刪除student表中department這列
alter table student drop department;

8:修改表名

語法格式:

rename table 表名 to 新表名;

例如:

# 將表student改名為stu
rename table student to stu

DML語法基本介紹

DML是指數(shù)據(jù)操作語言,英文全稱是Data Manipulation Language,用來對(duì)數(shù)據(jù)庫中標(biāo)的數(shù)據(jù)幾列進(jìn)行更新。

關(guān)鍵字:

  • 插入Insert

  • 刪除delete

  • 更新update

數(shù)據(jù)插入

  • 語法格式

insert into 表(列名1,列表2,列表3...) values(值1,值2,值3...);// 向表中插入某些
insert into 表 values(值1,值2,值3...);// 向表中插入所有列

例子:

向表中插入所有列

insert into student(sid, name, gender, age, birthday, address,department)
values (1,'tom','男',18,'2000-01-01','鄭州','銷售部');
?insert into student values (2,'jerry','女',28,'2001-01-01','北京','研發(fā)部');

一次性插入多條數(shù)據(jù)

insert into student(sid, name, gender, age, birthday, address,department)
values (3,'tom1','男',18,'2000-01-01','鄭州','銷售部'),

?????????? (4,'corky1','女',18,'2001-01-01','北京','法務(wù)部');
? ? ?
insert into student values (5,'jerry','女',28,'2001-01-01','北京','研發(fā)部'),

???????????????????????????????????????? (6,'yi','男',39,'2002-01-01','上海','研發(fā)部');

數(shù)據(jù)修改

  • 語法格式

update 表名 set 字段名=值,字段名=值...;
update 表名 set 字段名=值,字段名=值... where 條件;

例子:

將所有學(xué)生的地址修改為河南
update student ?set address='河南';
?
將id為1的學(xué)生的地址修改為河南
update student set address='河南' where id=1;
?
將id為2的學(xué)生的地址修改為北京,成績(jī)修成績(jī)修改為100
update student set address='北京',score=100 where id=2

數(shù)據(jù)刪除

  • 語法格式:

delete from 表名[where 條件];
truncate table 表名 或者truncate 表名

例子:

1:刪除sid為3的學(xué)生數(shù)據(jù)
delete from student where sid=3;
2: 刪除表所有數(shù)據(jù)
delete from student;
3:清空表數(shù)據(jù)
truncate table student;
truncate student;

注意:delete和truncate原理不同,delete只刪除內(nèi)容,而truncate類似于drop table,可以理解為是將整個(gè)表刪除,然后再創(chuàng)建該表。

實(shí)例代碼

?

DQL語法概述

  • 概念

    1. 數(shù)據(jù)庫管理系統(tǒng)一個(gè)重要功能就是數(shù)據(jù)查詢,數(shù)據(jù)查詢不應(yīng)只是簡(jiǎn)單返回?cái)?shù)據(jù)庫中存儲(chǔ)的數(shù)據(jù),還應(yīng)該根據(jù)需要對(duì)數(shù)據(jù)庫進(jìn)行篩選以及確定數(shù)據(jù)以什么樣的格式顯示。

    2. MySQL提供了功能強(qiáng)大,靈活的語句來實(shí)現(xiàn)這些操作。

    3. MySQL數(shù)據(jù)庫使用select語句來查詢數(shù)據(jù)。

  • 應(yīng)用?

基本查詢

  • 語法格式

select
[all|distinct]
<目標(biāo)列的表達(dá)式1> [別名],
<目標(biāo)列的表達(dá)式2> [別名]...
from <表名或視圖名> [列名],<表名或視圖名> [別名]...
[where<條件表達(dá)式>]
[group by<列名>
[having<條件表達(dá)式>]]
[order by<列名>[asc|desc]]
[limit<數(shù)字或者列表>];

  • 簡(jiǎn)化版語法

select *| 列名 from 表 where 條件

  • 數(shù)據(jù)準(zhǔn)備

創(chuàng)建數(shù)據(jù)庫和表

-- 創(chuàng)建數(shù)據(jù)庫
create database if not exist mydb2;
use mydb2;
-- 創(chuàng)建商品表:
create table product(
pid int primary key auto_increment, -- 商品編號(hào)
pname varchar(20) not null , -- 商品名字
price double, ?-- 商品價(jià)格
category_id varchar(20) -- 商品所屬分類
);

  • 添加數(shù)據(jù)

insert into product values(null,'海爾洗衣機(jī)',5000,'c001');
insert into product values(null,'美的冰箱',3000,'c001');
insert into product values(null,'格力空調(diào)',5000,'c001');
insert into product values(null,'九陽電飯煲',200,'c001');
insert into product values(null,'啄木鳥襯衣',300,'c002');
insert into product values(null,'恒源祥西褲',800,'c002');
insert into product values(null,'花花公子夾克',440,'c002');
insert into product values(null,'勁霸休閑褲',266,'c002');
insert into product values(null,'海瀾之家衛(wèi)衣',180,'c002');
insert into product values(null,'杰克瓊斯運(yùn)動(dòng)褲',430,'c002');
insert into product values(null,'蘭蔻面霜',300,'c003');
insert into product values(null,'雅詩蘭黛精華水',200,'c003');
insert into product values(null,'香奈兒香水',350,'c003');
insert into product values(null,'SK-II神仙水',350,'c003');
insert into product values(null,'資生堂粉底液',180,'c003');
insert into product values(null,'老北京方便面',56,'c004');
insert into product values(null,'良品鋪?zhàn)雍Ыz',17,'c004');
insert into product values(null,'三只松鼠堅(jiān)果',88,null);

數(shù)據(jù)準(zhǔn)備

1:創(chuàng)建數(shù)據(jù)庫

create database if not exists mydb2;
use mydb2;

2:創(chuàng)建商品表

create table if not exists product(
?? pid int primary key auto_increment,-- 商品編號(hào)
?? pname varchar(20) ,-- 商品名稱
?? price double, -- 商品價(jià)格
?? category_id int -- 商品所屬分類
);

?alter table product modify category_id varchar(20);

3:添加數(shù)據(jù)

insert into product values(null,'海爾洗衣機(jī)',5000,'c001');
insert into product values(null,'美的冰箱',3000,'c001');
insert into product values(null,'格力空調(diào)',5000,'c001');
insert into product values(null,'九陽電飯煲',200,'c001');
insert into product values(null,'啄木鳥襯衣',300,'c002');
insert into product values(null,'恒源祥西褲',800,'c002');
insert into product values(null,'花花公子夾克',440,'c002');
insert into product values(null,'勁霸休閑褲',266,'c002');
insert into product values(null,'海瀾之家衛(wèi)衣',180,'c002');
insert into product values(null,'杰克瓊斯運(yùn)動(dòng)褲',430,'c002');
insert into product values(null,'蘭蔻面霜',300,'c003');
insert into product values(null,'雅詩蘭黛精華水',200,'c003');
insert into product values(null,'香奈兒香水',350,'c003');
insert into product values(null,'SK-II神仙水',350,'c003');
insert into product values(null,'資生堂粉底液',180,'c003');
insert into product values(null,'老北京方便面',56,'c004');
insert into product values(null,'良品鋪?zhàn)雍Ыz',17,'c004');
insert into product values(null,'三只松鼠堅(jiān)果',88,null);

  • 簡(jiǎn)單查詢操作

查詢所有的商品

select * from product;
select pid,pname,price,category_id from product;

查詢商品名和商品價(jià)格

select? price,pname from product;

別名查詢,使用的關(guān)鍵字是as,(as可以省略的)

表別名
? ?select * from product as p;
? ?select * from product p;
? ?select p.id,u.id from product p,user u;

列表名
? ?select pname as 商品名,price as 商品價(jià)格 from product;

去掉重復(fù)值

select distinct price from product;

每一行和每一行都不一樣

select distinct * from product;

查詢結(jié)果是表達(dá)式(運(yùn)算查詢):將所有商品加價(jià)10元進(jìn)行展示

select pname,price+10 as 新價(jià)格,price from product;

運(yùn)算符

  • 算數(shù)運(yùn)算符

  • 比較運(yùn)算符

  • 邏輯運(yùn)算符

  • 位運(yùn)算符

位運(yùn)算符是在二進(jìn)制數(shù)上進(jìn)行計(jì)算的運(yùn)算符。位運(yùn)算會(huì)先將操作數(shù)變成二進(jìn)制數(shù),進(jìn)行位運(yùn)算。然后再將計(jì)算結(jié)果從二進(jìn)制數(shù)變回十進(jìn)制數(shù)。

①:算數(shù)運(yùn)算符

算數(shù)運(yùn)算符

select 6+2;
select 6-2;
select 6*2;
select 6/2;
select 6 div 2;
select 6 mod 2;

將所有商品價(jià)格+10元
select price+10 as 價(jià)格 from product;
?
將所有商品的價(jià)格上調(diào)10%
select price*(1+0.1) as 價(jià)格 from product;

條件查詢

算數(shù)運(yùn)算符

?

代碼實(shí)現(xiàn):

查詢商品名稱為“海爾洗衣機(jī)”的商品所有信息
select * from product where pname='海爾洗衣機(jī)';
?
查詢價(jià)格為800商品
select * from product where price=800;

查詢價(jià)格不是800商品
select * from product where price <>800;
select * from product where price!=800;
select * from product where not (price=800);

查詢商品價(jià)格大于等于60元的所有商品信息
select * from product where price >=60;

查詢商品價(jià)格在200到1000之間所有商品
select * from product where price between 200 and 1000;
select * from product where price >= 200 and price<= 1000;
select * from product where price >= 200 && price<= 1000;

查詢商品價(jià)格在200或800的所有商品
select * from product where price=200 or price=800;
select * from product where price=200 || price=800;
select * from product where price in(200,800);

查詢含有'褲'字的所有商品
select * from product where pname like '%褲%'; -- %任意字符

查詢以‘?!_頭的所有商品
select * from product where pname like '海%';
?
查詢第二個(gè)字為'蔻'的所有商品
select * from product where pname like '_蔻%';
?
查詢category_id為null的商品
select * from product where category_id is null;
?
查詢category_id不為null的商品
select * from product where category_id is not null;

使用Least求取最小值
select LEAST(10,20,30) as small_number;
select least(10,null,30); -- 如果求最小值有一個(gè)null值,不會(huì)比較直接null

使用greatest求最大值
select greatest(10,20,30) as big_number ;
select greatest(10,null,30) as big_number ;
如果求最大值有一個(gè)null值,不會(huì)比較直接null

排序查詢

聚合查詢

?

?

?

聚合函數(shù)--null值得處理

分組查詢

?

分頁查詢

Insert into Select

http://www.risenshineclean.com/news/11354.html

相關(guān)文章:

  • 姑蘇區(qū)做網(wǎng)站肇慶網(wǎng)站搜索排名
  • 做網(wǎng)站公司找哪家百度seo怎么樣優(yōu)化
  • 邢臺(tái)網(wǎng)站網(wǎng)頁設(shè)計(jì)公司江西百度推廣公司
  • 網(wǎng)站開發(fā)設(shè)計(jì)方案拓客團(tuán)隊(duì)怎么聯(lián)系
  • 徐州市城鄉(xiāng)建設(shè)局網(wǎng)站適合seo的建站系統(tǒng)
  • 3d網(wǎng)站制作seo網(wǎng)站推廣軟件
  • 建立自己的網(wǎng)站平臺(tái)需多少錢優(yōu)化系統(tǒng)軟件
  • 網(wǎng)站怎么做才是對(duì)搜索引擎友好百度賬號(hào)客服人工電話
  • 哪個(gè)網(wǎng)站可以做問卷調(diào)查中國(guó)網(wǎng)絡(luò)營(yíng)銷公司排名
  • 企業(yè)獨(dú)立官方網(wǎng)站網(wǎng)址怎么做百度搜索官方網(wǎng)站
  • 網(wǎng)站建設(shè)接外包流程圖網(wǎng)站seo平臺(tái)
  • 房地產(chǎn)網(wǎng)站建設(shè)平臺(tái)免費(fèi)p站推廣網(wǎng)站入口
  • 網(wǎng)站開發(fā)廣東seo搜索
  • wordpress 博客 簡(jiǎn)書有必要買優(yōu)化大師會(huì)員嗎
  • 邯鄲網(wǎng)站建設(shè)制作怎么給自己的網(wǎng)站設(shè)置關(guān)鍵詞
  • 做網(wǎng)站開發(fā)需要培訓(xùn)嗎網(wǎng)站市場(chǎng)推廣
  • 南京網(wǎng)站建設(shè)價(jià)位外貿(mào)平臺(tái)有哪些比較好
  • 網(wǎng)站服務(wù)器轉(zhuǎn)移視頻嗎武漢最新疫情
  • wordpress圖片在哪惠州seo代理
  • discuz論壇 整合到網(wǎng)站漯河網(wǎng)站seo
  • 網(wǎng)站 如何備案培訓(xùn)心得體會(huì)800字
  • wordpress訂單推送微信sem與seo
  • 做國(guó)外銷售都上什么網(wǎng)站不付費(fèi)免費(fèi)網(wǎng)站
  • ps做網(wǎng)站頁面美工班級(jí)優(yōu)化大師官方免費(fèi)下載
  • 維恩圖在線制作網(wǎng)站站長(zhǎng)工具的使用seo綜合查詢運(yùn)營(yíng)
  • 做網(wǎng)站不用服務(wù)器嗎鄭州網(wǎng)站開發(fā)公司
  • 找做報(bào)紙的背景圖去什么網(wǎng)站海外推廣代理商
  • 個(gè)人如何開網(wǎng)站東莞網(wǎng)絡(luò)推廣營(yíng)銷
  • 哪家網(wǎng)站建設(shè)服務(wù)好開發(fā)網(wǎng)站需要多少錢
  • 懷化市優(yōu)化辦電話seo快速排名優(yōu)化公司