当前位置: 首页 > news >正文

校园网站建设经费申请报告廊坊关键词排名优化

校园网站建设经费申请报告,廊坊关键词排名优化,自己做优惠劵网站赚钱吗,电子商务网站网站建设目录 1. 常用数据类型 2. 约束 4. 数据库操作 5. 数据表操作 1. 常用数据类型 int 整型double 浮点数varchar 字符型data 年月日datetime 年月日 时分秒2. 约束 主键 primary key : 物理上存储的顺序(存在真实排序), 主键…

目录

1. 常用数据类型

2. 约束

4. 数据库操作

5. 数据表操作


1. 常用数据类型

  • int                整型
  • double         浮点数
  • varchar        字符型
  • data             年月日
  • datetime      年月日 时分秒

2. 约束

  • 主键 primary key : 物理上存储的顺序(存在真实排序), 主键都是非空/唯一的
  • 非空 not null : 此字段不允许为空
  • 唯一 unique  : 此字段不允许重复
  • 默认 default : 当不填写此字段时, 会使用默认值
  • 外键 foreign key : 对关系数据进行约束, 当为关键字段填写值时, 会到关联的表中查询此值是否存在, 如果存在则填写成功, 如果不存在则填写失败并抛出异常
  • 虽然外键可以保证数据的有效性, 但在进行数据的增删查改时, 都会降低数据库的性能, 故不推荐使用

4. 数据库操作

--查看数据库
show databases;--创建数据库
create database 数据库名;--删除数据库
drop database 数据库名;--选择数据库
use 数据库名;--查看当前使用的数据库
select database();

5. 数据表操作

查看表:

--查看当前数据库中的所有表
show tables;--查看表结构
desc 表名;

增添数据:

--创建表格示例
create table if not exists `test_01`(`id` int unsigned auto_increment comment '编号',`title` varchar(100) not null comment '标题',`author` varchar(40) not null comment '作者',`cdate` date comment '日期',primary key (`id`)
)engine=InnoDB  default charset=utf8 comment='测试表格01';
-- if not exists 表名 : 表示若该表不存在则创建
-- auto_increment : 表示从上一条数据自增1
-- comment : 注释字段--新增字段    
alter table 表名 add 字段名 字段数据类型及约束;              --系统默认值为null    
--设置的默认值要与数据类型匹配--写入数据
insert into 表名(字段名1,字段名2
)value(内容1, 内容2, ...);--批量写入
insert into 表名(字段名1,字段名2
)value(内容1, 内容2, ...),(内容1, 内容2, ...),...(内容1, 内容2, ...);

删除数据:

--删除表格
drop table 表名;--删除数据
delete from 表名 where 条件;

修改数据:

--修改字段名称
alter table 表名 change 原名 新名 类型及约束;--更新数据
update  表名
set字段1=...,字段1=...,...
where 条件;

查询数据:

--查询数据
select * from 表名;        --查询表里所有数据--限制查询数据条数
select * form 表名
limit 数据条数;--查找字段数据
select字段1,字段2,...
from 表名;--多表查询
select表1.字段x,表1.字段y,...表2.字段z,...
form 表1, 表2;--条件查询
select * 
from 表名1, 表名2, ...
where 条件;select *
from 表名
where 条件1        --选定表格之后,选择数据之前
having 条件2;      --数据全部计算完之后进行筛选--起别名
select本名1 as 别名1,本名2 as 别名2,...
from 表本名 as 表别名
limit 数据量;--按字段数据去重查询
select distinct字段1,字段2,...
from 表名;--模糊查询1
select *
from 表名
where 字段1 like '_est'        --下划线可任意匹配一个字符
where 字段2 like '%e%';        --百分号可任意匹配多个字符, 可以匹配也可以不匹配--模糊查询2
select *
from 表名
where 字段名 in ('test1', 'test2',...);--模糊查询3
select *
from 表名
where 字段名 between x and y;    --最好用于查询数字/日期, 返回x到y之间的模糊匹配结果--关联, 将两张表上下拼接
--两张表关联的字段名可以不相同, 但字段数量和字段类型要相同
--union distinct 关联时去重
select id,name
from table1
union
selectid,name
from table2;--排序
--默认是从小到大排序, 加上desc是从大到小排序
--每个字段后面的参数只代表这个字段的排序法则
select * from 表名
order by 字段1, 字段2 desc       --哪个字段写在前面, 哪个字段优先排
limit 10;--聚合
--选择想要查询的信息
selectcount(0)        --统计数据条数,max(字段名)    --找最大值,min(字段名)    --找最小值,avg(字段名)    --求平均值...
from 表名
where 条件;         --统计符合条件的数据条数--分组
select字段1,字段2,count(0)    --统计每个分组的人数
from 表名
where 条件
group by 字段1, 字段2;    --用group by去重比distinct效率高--分组统计
selectcoalesce(字段1, 'total'),coalesce(字段2, 'total')
from 表名
where 条件
group by 字段1, 字段2
with rollup;--链接查询
--可同时关联两张表或者多张表
--join默认为内连接 inner join
--内连接: 保留两个关联表的交集数据
select别名1.字段1,别名1.字段2,别名1.字段3,别名2.字段1,别名2.字段2...
from 表名1 (别名1)        --主表
join 表名2 (别名2)        --副表on 别名1.关联字段 = 别名2.关联字段and 副表条件...
where 主表条件条件
limit 数据量;--左连接 left join
--保留主表的全部数据和关联表的交集数据
with 别名1 as (select *from 表名1where 条件
)
,别名2 as (select *from 表名2where 条件
)
select 字段...
from 别名1            --主表
left join 别名2       --副表on 别名1.关联字段 = 别名2.关联字段
where 条件;           --where里面的条件对应from后面的表(别名1)的条件--右连接 right join
--通过调换字段顺序可以将右关联的表改为左关联
with 别名1 as (select *from 表名1where 条件
)
,别名2 as (select *from 表名2where 条件
)
select 字段...
from 别名1             --副表
right join 别名2       --主表on 别名1.关联字段 = 别名2.关联字段
where 条件;--外连接 outer join
--将两张表关联, 没有数据的位置由null补充, 只要其中一个表存在数据则返回数据
--通过其他的关联操作实现外关联--自关联
create table if not exists `city` (`id` int not null comment '编号',`name` varchar(100) comment '城市名称',`pid` varchar(4) comment '父id',primary key (`id`)
)engine=InnoDB default charset=utf8 comment='城市表格';insert into city(id,name,pid) values 
(1,'上海市',null),
(12,'闵行区',1),
(13,'浦东新区',1),
(2,'北京市',null),
(23,'朝阳区',2),
(24,'海淀区',2),
(25,'望京区',2),
(3,'广东省',null),
(31,'广州市',3),
(32,'东莞市',3),
(33,'珠海市',3),
(321,'莞城区',32);selecta.ID,a.name,b.ID,b.name,c.ID,c.name
from city a
left join city bon a.ID = b.PID
left join city con b.ID = c.PID
where a.PID is null;--子查询
select * from 表名
where 字段 >= (select avg(字段) from 表名);

总结:

--代码格式
select distinct字段
from 表名
join
where
group by
having 
order by
limit start, count--执行顺序
from 表名
join
where
group by
select distinct 字段
having
order by
limit start, count

内置函数:

--日期 now  
now();   --当前日期 时间
year(now());     --年
month(now());    --月
day(now());      --日select year(now());--字段长度 length
length(对象字段) from 表名;--设置返回值小数位数 round
select round(对象字段, 小数位数) from 表名;--反转字符串 reverse
select reverse(对象字符串);--截取字符串 substring
select substring(对象字符串, start, length);--判空 ifnull / nvl / coalesce
select ifnull(对象, 默认值);      --如果对象为null, 则用默认值替换--条件判断 case when
select
case when 条件1 then ...when 条件2 then ...else ...end 新增字段
from 表名select emp_no,case when emp_no > 10020 then '大'     --最优先when emp_no > 10010 then '中'else '小'end '编号等级'
from dept_emp
where emp_no < 10050
limit 30;--分组(维度)聚合 grouping sets
--开窗函数 partition by
--function(column) over(partiton by 字段1,字段2...) 新增字段
--function通常为聚合函数/排序函数--分类统计不同部门不同性别的人数
with a as (select a.emp_no,a.gender,b.dept_nofrom employees a join dept_emp b on a.emp_no = b.emp_no
)
select distinctdept_no,gender,count(emp_no) over (partition by dept_no, gender) dept_cnt
from a;--排序函数
--row_number()  排序名次累加, 即使数据相同也累加                  1 2 3 4 5 6
--rank()        排序名次可能相同, 遇到数据相同则跳过该名次         1 1 3 4 4 6
--dense_rank()  排序名次可能相同, 遇到数据相同则从上一个名次累加   1 1 2 2 2 3 4
select row_number() over(order by 字段) 新增字段;
select rank() over(order by 字段) 新增字段;
select dense_rank() over(order by 字段) 新增字段;--查询写入 insert into select
--将查询到的数据写入到另一个表格中, 要求字段一一对应


文章转载自:
http://corpselike.tbjb.cn
http://polyacid.tbjb.cn
http://perry.tbjb.cn
http://toluidide.tbjb.cn
http://dwelt.tbjb.cn
http://crape.tbjb.cn
http://nonary.tbjb.cn
http://liner.tbjb.cn
http://mackerel.tbjb.cn
http://bock.tbjb.cn
http://configurate.tbjb.cn
http://macedonia.tbjb.cn
http://fretfully.tbjb.cn
http://plasmolysis.tbjb.cn
http://sequestrable.tbjb.cn
http://confectionery.tbjb.cn
http://pirineos.tbjb.cn
http://pruina.tbjb.cn
http://passivity.tbjb.cn
http://antimonous.tbjb.cn
http://calvarian.tbjb.cn
http://alitalia.tbjb.cn
http://auew.tbjb.cn
http://girasol.tbjb.cn
http://gymnospermous.tbjb.cn
http://localizable.tbjb.cn
http://pyramidalist.tbjb.cn
http://gherkin.tbjb.cn
http://hype.tbjb.cn
http://unassailed.tbjb.cn
http://leaven.tbjb.cn
http://namaqualand.tbjb.cn
http://californite.tbjb.cn
http://geoisotherm.tbjb.cn
http://sciophyte.tbjb.cn
http://eventually.tbjb.cn
http://predistortion.tbjb.cn
http://posterolateral.tbjb.cn
http://juvenilia.tbjb.cn
http://midpoint.tbjb.cn
http://porcino.tbjb.cn
http://chirography.tbjb.cn
http://preparental.tbjb.cn
http://provisionality.tbjb.cn
http://outwork.tbjb.cn
http://mumm.tbjb.cn
http://pinch.tbjb.cn
http://greatly.tbjb.cn
http://rilievi.tbjb.cn
http://naoi.tbjb.cn
http://wharfman.tbjb.cn
http://unfeed.tbjb.cn
http://farinha.tbjb.cn
http://pneumatolytic.tbjb.cn
http://opponency.tbjb.cn
http://curtail.tbjb.cn
http://lathi.tbjb.cn
http://tuning.tbjb.cn
http://crowbill.tbjb.cn
http://geobiological.tbjb.cn
http://barbital.tbjb.cn
http://whipless.tbjb.cn
http://underestimation.tbjb.cn
http://drafty.tbjb.cn
http://stealthily.tbjb.cn
http://begohm.tbjb.cn
http://deodand.tbjb.cn
http://althea.tbjb.cn
http://airbed.tbjb.cn
http://sucrier.tbjb.cn
http://carillon.tbjb.cn
http://resaddle.tbjb.cn
http://sholom.tbjb.cn
http://beefsteak.tbjb.cn
http://longevity.tbjb.cn
http://mineralography.tbjb.cn
http://novennial.tbjb.cn
http://crenelet.tbjb.cn
http://schoolboy.tbjb.cn
http://unregretted.tbjb.cn
http://ferrocyanogen.tbjb.cn
http://pendant.tbjb.cn
http://imperforation.tbjb.cn
http://gppm.tbjb.cn
http://thrave.tbjb.cn
http://lyard.tbjb.cn
http://microscale.tbjb.cn
http://completeness.tbjb.cn
http://disseizor.tbjb.cn
http://villiform.tbjb.cn
http://overwrought.tbjb.cn
http://recognizability.tbjb.cn
http://genbakusho.tbjb.cn
http://tracer.tbjb.cn
http://baboonery.tbjb.cn
http://cephaloid.tbjb.cn
http://fluoroscopy.tbjb.cn
http://scrapple.tbjb.cn
http://miri.tbjb.cn
http://pika.tbjb.cn
http://www.dt0577.cn/news/92028.html

相关文章:

  • 如何说服老板做网站网络建站优化科技
  • 狮山网站制作国际重大新闻
  • 耒阳做网站合肥网络公司
  • ecshop仿小米商城b2c网站程序百度权重
  • 网站 数据备份手机制作网页
  • 网站建设价格需要多少钱免费推广
  • 广州网站制作开发公司常见的推广方式有哪些
  • 网站制作公司网站建设公司漳州网络推广
  • 政府网站安全如何做上海优化seo
  • python做网站感觉好费劲我赢seo
  • 青岛公司做网站的价格新郑网络推广外包
  • 天长做网站做销售有什么技巧和方法
  • 网站制作帐户设置学生个人网页制作成品
  • 广州网站建设推广服务智慧营销系统平台
  • 我的网站刚换了一个模板收录很多就是没排名b站推广链接
  • b2b网站制作平台百度网站客服
  • vue大型网站开发代写1000字多少钱
  • 网站设计与开发专业优化方案怎么写
  • 传统纸媒公司网站建设需求软文广告经典案例
  • 中山网站建设哪家好重庆seo点击工具
  • wordpress.com变装seoul是韩国哪个城市
  • 吐槽做网站如何做电商
  • 网站权重的重要性杭州正规引流推广公司
  • 自学编程的网站百度账号人工申诉
  • 找我家是做的视频网站关键词收录查询工具
  • vps做网站空间网站建设企业
  • 网站开发 前台代码公司网站搭建
  • 品牌建设 企业要有利于seo优化的是
  • 营销网站开发哪家强吉林关键词优化的方法
  • 怎么做php网站产品推广方案要包含哪些内容