位置: IT常识 - 正文

大二一个学期学这么点内容,没有概念,只有实操(大二一学期学分多少合适)

编辑:rootadmin
大二一个学期学这么点内容,没有概念,只有实操

推荐整理分享大二一个学期学这么点内容,没有概念,只有实操(大二一学期学分多少合适),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:大二一个学期几个月,大二上学期有几个月,大二一个学期学几门课,大二一学期学分多少合适,大二一个学期学几个专业,大二一学期学分24分正常吗,大二一个学期学几门课,大二一个学期学几门课程,内容如对您有帮助,希望把文章链接给更多的朋友!

如何查看所有的数据库:

Show databases;

如何进入某个数据库: use xxx;

如何新进数据库:

Create database jx;

如何删除数据库:

Drop database jx;

如何查看所有的表格:

Show tables;

如何创建数据表:

create table teacher(id int,name

varchar(10),address varchar(100),score float,time date);

如何修改表(添加列):

alter table teacher add phone varchar(11);

如何修改表(删除列):

alter table teacher drop score;

如何修改表(修改列):

alter table teacher modify phone int;

如何删除表:

drop table student;

表的约束管理:

非空约束 not null

唯一约束 unique

主键约束 primary key

默认约束 default

示例:

create table student

(id int primary key, name varchar(10) not null, phone varchar(11) default "18502348498",address

varchar(100) unique)

对于数据库中表的操作有4种操作:

增删改查

增加操作:

INSERT INTO employees_cn

 (employee_name, employee_address, employee_price) VALUES ("李兰","长沙",14500),("李兰妈妈","株洲",9000);

删除操作:

DELETE FROM employees_cn WHERE employee_name="诸葛亮";

DELETE FROM employees_cn WHERE employee_name="周杰" AND employee_address = "深圳";

修改操作:

UPDATE employees_cn set employee_address = "佛山" , employee_price = 51000 WHERE employee_name = "马超";

查询操作:

SELECT * from employees_cn WHERE employee_price >= 20000;

SELECT 1+2*8+5/2 as result;

去重:

SELECT   DISTINCT   employees_price    FROM  employees_cn;

分页:

SELECT * FROM city LIMIT 3,15;

解释:3:是从4开始,不包括3

15:往后数15行。

使用完全限定表名:

SELECT city.population FROM city;

排序:

SELECT*from employees_us    ORDER  BY    employees_price;

升序:asc,可以不写,因为默认升序。

降序:desc

以多个序列排序:

当第一个序列起作用时,那么后面的列不起作用,反之,后面的列才起作用。

SELECT  *  from    employees_us       ORDER  BY   employees_price,employees_name;

Where的使用:

SELECT * from  employees_cn where employees_price BETWEEN 10000 and 20000;

SELECT  *  from    employees_cn       where

employees_price>=10000and employees_price<=20000;

SELECT   *   from    employees_cn       where

employees_price >= 10000 and employees_price <= 20000

ORDER BY employees_price;

SELECT  *  from    employees_cn       where

Employees_name is null;

组合where使用:

And:

Select * form employees_cn where employees_name=”周杰” and employees_address=”抚州”;

Or:

Select * form employees_cn where employees_name=”周杰” or employees_address=”抚州”;

In:

Select * form employees_cn where employees_id=18 or employees_id=21 or employees_id=23;

等于

Select * form employees_cn where employees_id in(18,21,23);

Not in:

Select * form employees_cn where employees_address not in(“抚州”,”株洲”,”上海”);

Like的使用

当like单独使用的时候,它相当于=。

Select * from employees_us where employee_name like “jerry”;

通配符:

%:表示任意多个字符

Select * from employees_us where employee_name like “%jerry%”;

_:表示任意一个字符

Select * from employees_cn where employee_name like “张_”;

转义字符:

Select * from employees_cn where employee_name like “jerry/_%”escape”/”;

拼接字段

SELECT concat(employee_name,"---",employee_address) as "结果" FROM `employees_cn`;

计算字段

SELECT sid*score FROM `score`;

函数的使用

SELECT concat(employee_name,"---",employee_address) as "结果" FROM `employees_cn`

SELECT sid*score from score;

select LEFT("你好,你吃饭了吗?",4)

select RIGHT("你好,你吃饭了吗?",4)

select left(employee_name,2) from employees_cn where employee_id = 21

select LENGTH("你好")

select length(employee_name) from employees_cn where employee_id = 21

select SUBSTRING("你好,你吃饭了吗???",2)

select SUBSTRING("你好,你吃饭了吗???",2,4)

select SUBSTRING(employee_name,2) from employees_cn where employee_id = 21

大二一个学期学这么点内容,没有概念,只有实操(大二一学期学分多少合适)

日期处理函数

获取当前日期

SELECT NOW();

SELECT SYSDATE();

SELECT CURRENT_TIMESTAMP;

SELECT CURRENT_TIMESTAMP();

SELECT CURRENT_DATE;

SELECT CURRENT_TIME;

日期格式化:

select DATE_FORMAT('2008-08-09 22:23:01','%y-%m-%d %h:%i:%s');

字符串变日期:

select STR_TO_DATE('08/09/2008','%m/%d/%y');

时间变秒

select TIME_TO_SEC('01:00:05');

天数变日期

SELECT MAKEDATE(2019,300);

SELECT DAYOFYEAR("2019-10-23");

数值函数:

四舍五入

select ROUND(48.3847)

select ROUND(48.3847,1)

select MOD(CEIL(ROUND(employee_price)), 10) from employees_cn

向上取整

select CEIL(48.2)

向下取整

select FLOOR(48.9)

取余

SELECT MOD(18,3)

开方

SELECT SQRT(9)

指数

select POW(2,10)

绝对值

select ABS(-9)

平均值

Select avg(score) from score

计数

Select count(*) from score

Select count(distinct name) from score

最值

Select max(score), name from score

Select min(score), name from score

求和

Select sum(score) from score

分组查询

SELECT round(avg(score)),class from score GROUP BY class;

过滤分组

SELECT avg(score) as a,class from score GROUP BY class HAVING a < 80;

SELECT score from score where score < 80

where作用于表之后,having作用于组之后

select子句顺序

from, on, join, where, group by, having, select, distinct, order by, limit

select round(avg(score),1) as a, class from score where score > 70 GROUP BY class HAVING a >= 85 ORDER BY a LIMIT 0,2;

子查询:

select * from score where score = (select min(score) from score)

也就等于下面两个语句之和

select min(score) from score;

select * from score where score = 60;

连接查询

适用于多表操作

外连接:包括左连接、右连接

SELECT a.*, b.* from student_info a left join student_score b on a.student_id = b.student_id

SELECT a.*, b.* from student_info a right join student_score b on a.student_id = b.student_id

笛卡尔积连接:包括内连接、自然连接、交叉连接、自连接(原理: 笛卡尔积)

select a.*, b.* from student_info a inner join student_score b

select a.*, b.* from student_info a inner join student_score b on a.student_id = b.student_id

SELECT A.*, B.* from student_info A cross join student_score B

SELECT A.*, B.* from student_info A cross join student_score B on A.student_id = B.student_id

SELECT A.*, B.* from student_info A natural join student_score B

select B.* from score as A join score as B on A.score < B.score and A.name = "王兰"

组合查询

select vend_id, prod_id, prod_price from products where prod_price < 5 union select vend_id, prod_id, prod_price from products where vend_id in (1001,1002)

select vend_id, prod_id, prod_price from products where prod_price < 5 union all select vend_id, prod_id, prod_price from products where vend_id in (1001,1002)

select vend_id, prod_id, prod_price from products where prod_price < 5 union all select vend_id, prod_id, prod_price from products where vend_id in (1001,1002) order by prod_price

union的结果去重,而union all的结果不去重

视图

如何创建视图 create view abc as select * from employees_cn where employee_id BETWEEN 14 and 20

视图的操作和表的操作相同

索引

作用:提高检索速度

如何创建索引 create index aaa on employees_cn(employee_name, employee_price)

如何使用索引

事务

概念特征 原子性 一致性 隔离性 持续性

start TRANSACTION;

INSERT into score (name, class, score, sex, phone) VALUES ("智慧化", "软件1" ,'43', "女", '1213');

SAVEPOINT p;

INSERT into score (class, score, sex, phone) VALUES ("张晓霞", "软件1", "23", "女", '12133');

ROLLBACK to SAVEPOINT p;

commit;

常量

变量

用户变量 @后为变量

set @name = "李兰";

select * from employees_cn where employee_name = @name;

select @xxx := (@xxx := 8) + 2;

局部变量

作用于存储过程

DECLARE abc int DEFAULT 0;

系统变量

Select CURRENT_TIME

Select CURRENT_USER

If控制语句

Case控制语句

循环控制语句

自定义函数

存储过程

触发器

本文链接地址:https://www.jiuchutong.com/zhishi/300399.html 转载请保留说明!

上一篇:【中兴】web训练营~一文带你走进前端 | 百图制作(中兴网管操作手册)

下一篇:基于 BERT 实现的情感分析(文本分类)----概念与应用(bert的原理)

  • 微信支付宝等三方支付平台余额属于货币资金吗
  • 从价从量复合计征
  • 资源税征收原则
  • 出售交易性金融资产发生的净损失应计入营业外支出
  • 企业给员工的福利取消了可以劳动仲裁么
  • 贴现法付息的有效年利率
  • 个税抵扣未及时填报
  • 理财产品产生的利息怎么入账
  • 预付账款怎么处理
  • 投标函中的其他是指什么
  • 房地产公司环境
  • 牛奶公司饲养奶牛生产牛奶
  • 总公司可以给分公司买车吗
  • 计提坏账的递延税收
  • 用于研发的设备会计分录
  • 酒店代金券怎么做账
  • 合资公司51%股东的权限
  • 上个月少计了成本要怎么办
  • 分支机构第要交企业所得税吗?
  • 国家认定的高新技术企业是什么意思
  • 发票作废相关规定
  • 公休假补贴多少钱
  • 购买债券投资的交易费用
  • 小规模自开专票税率是1%还是3%
  • 居民小区人防设施主要是什么
  • 未开票收入如何记账
  • 先发货后开票的销售业务流程
  • linux deepin怎么样
  • 如何在excel中计算两列数值的差
  • NPFMSG.exe - NPFMSG是什么进程 有什么用
  • 专项维修基金会计核算应当遵循及时性原则
  • 对公帐户定期存款利率
  • 客户申请退款商家拒绝退货退款会有什么效果
  • 应退税款抵扣欠税款的账务处理
  • 企业所得税如何更正申报
  • 税控盘的发票怎么做账
  • Win11 KB5025239 / KB5025224 累积更新今日发布
  • 机器学习--使用朴素贝叶斯进行垃圾邮件分类
  • ts入门教程
  • 微调是调哪里
  • win11怎么通过ip连接打印机
  • php实现会话的步骤
  • 服务型制造收入
  • mkfifo命令
  • 企业所得税报表怎么更正
  • 总公司发票可以从分公司付款吗
  • dedecms采集怎么用
  • python索引值-1和位置-1
  • 海关缴款书上完税价格含增值税吗
  • 印花税按金额还是价税合计交
  • 民非企业是否可以做酒
  • sqlserver2016使用方法
  • 入股资金打入公司账户
  • 基本户是活期还是定期
  • 营业执照办理税务登记需要什么资料
  • 其他债权投资的公允价值变动计入什么科目
  • 所得税费用是什么意思
  • 增值税普通发票查询
  • 公司开办期间购买的工具
  • 买商品赠送赠品怎么做账
  • 增值税普通发票查询
  • 独立核算的重要性
  • centos怎么扩容
  • 用OpenBSD 3.8 release自带的FTPD架设FTP服务器
  • windows缓存写入失败,数据怎么找回
  • WIN7系统安装
  • xp清理系统的命令
  • win7如何设置网络连接路由器
  • opengl英文
  • js的上传文件
  • SQLite -- 嵌入式关系型数据库
  • ecmascript6教程
  • shell脚本实现批量移动文件
  • 基于javascript的毕业设计选题
  • rst.open
  • 安徽省国家税务局通用定额发票
  • 提高税务干部七种能力的意义
  • 乡土中国出版社不同内容一样吗
  • 宁波市国家税务局网上办税服务厅
  • 上海税务怎么样
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设