
mysql
上进的菜鸟
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
MySQL(查找自己的数据data在哪)
查找自己的数据data在哪 show global variables like "%datadir%";就能找到啦,不同版本是不一样的,所以这个比较好使我的在这里C:\ProgramData\MySQL\MySQL Server 8.0\Data\...原创 2018-06-24 16:40:45 · 7592 阅读 · 0 评论 -
数据的删除
###################数据的删除 ##################-- 1.drop&delete#1.drop table可以将表完全删除 #2.delete语句会留下表(容器),而删除表中的全部数据 -- 2.delete语句删除对象不是表或者列,而是行 -- 如果删除单个列的值可以采用update将其更新为Nulldelete from Pr...翻译 2018-07-20 21:03:02 · 939 阅读 · 0 评论 -
数据的更新
##################数据的更新 更新列!(删除的是行)#################-- 1.update...set...where...update Productset sale_price=sale_price*10where product_type='厨房用具';#使用null---变成清空 update Product set regis...翻译 2018-07-20 21:22:28 · 313 阅读 · 0 评论 -
事物
####################事务 ###################-- 事务是需要在同一个处理单元中执行的一系列更新处理的集合。-- commitSTART TRANSACTION; -- 将运动T恤的销售单价降低1000日元 UPDATE Product SET sale_price = sale_price - 1000 W...翻译 2018-07-20 21:54:06 · 1741 阅读 · 0 评论 -
视图的操作
########################视图################-- 视图保存的是select语句,大大节省空间 -- 视图的数据会随着原表的变化自动更新,-- 建议将经常使用的select语句做成视图 create view...as...#################1.创建视图create or replace view ProductSu...转载 2018-07-21 09:10:25 · 1339 阅读 · 0 评论 -
子查询
#######################子查询 (嵌套select)######################-- 1.内层select首先执行 -- 2.子查询最好都要用as取个别名 SELECT product_type, cnt_product FROM (SELECT * FROM (SELECT product_type, COUNT(*) AS cnt_pr...转载 2018-07-21 10:21:10 · 767 阅读 · 0 评论 -
SQL中各种函数
#####################各种各样的函数 ####################CREATE TABLE SampleMath (m NUMERIC (10,3), n INTEGER, p INTEGER);INSERT INTO SampleMath(m, n, p) VALUES (500, 0, NULL); INSERT INTO Samp...转载 2018-07-21 11:12:07 · 2177 阅读 · 0 评论 -
MySQL使用trick
-- 1.当命令输入错误而又无法改变时,只需要在分号前输入\c即可取消此命令-- 2.ctrl+/ 光标回到当前行的首端 快速注释-- 3.mysql -V 查看版本信息 -- mysql -u root -p 输入密码 show engines;-- 4. 查看支持的搜索引擎 show variables like 'performance_schema';-- 5.检查是...转载 2018-08-03 16:57:25 · 265 阅读 · 0 评论 -
约束
################约束#############-- PK: primary key主键约束-- NN: Not Null 非空约束 -- UQ: unique 唯一约束 -- BIN: 二进制存储 -- UN: unsigned 表示整数 -- ZF: zero fill数值中空白区域以0填补-- AI: auto increment自增约束 --...转载 2018-08-03 20:59:15 · 207 阅读 · 0 评论 -
索引
####################索引#####################.普通索引#####.唯一性索引unique#####.全文索引fulltext(只能在char varchar text)#####.单列索引 多列索引 空间索引(spatial) ############1.创建表示创建索引-- [unique/fulltext/ /spatial] ...转载 2018-08-04 10:13:47 · 296 阅读 · 0 评论 -
mysql编程 变量 运算符 流程控制语句
#################MySQL编程 ################-- DDL数据定义语言 :create drop alter -- DML数据操作语言:insert select update delete-- DCL数据控制语言:grant(授予权限)revoke(收回权限) -- MySQL增加了语言元素:常量 变量 运算符 函数 流程控制语句 注释 ##...转载 2018-08-04 15:15:04 · 735 阅读 · 0 评论 -
自定义函数
##############函数 ##############1.自定义函数 /*create function name ([func_parameter[,...])return typebegin //函数实现的语句 end*/delimiter $$create function sayhello(name varchar(50))returns varc...转载 2018-08-04 16:10:18 · 400 阅读 · 0 评论 -
(left join )where和on。。。and
在使用left jion时,on和where条件的区别如下:1、 on条件是在生成临时表时使用的条件,它不管on中的条件是否为真,都会返回左边表中的记录。2、where条件是在临时表生成好后,再对临时表进行过滤的条件。这时已经没有left join的含义(必须返回左边表的记录)了,条件不为真的就全部过滤掉。假设有两张表:表1:tab2id size 1 10 ...转载 2018-08-14 21:47:03 · 1049 阅读 · 0 评论 -
mysql之谓词like/in/between/exist
##################谓词#like /between /is null/is not null/in/exists################show databases;use xscj;CREATE TABLE SampleLike ( strcol VARCHAR(6) NOT NULL, PRIMARY KEY (strcol));START TR...翻译 2018-08-02 21:04:38 · 722 阅读 · 0 评论 -
case表达式
#######################CASE表达式######################1.搜索case表达式use xscj;-- case when <求值表达式> then <表达式>-- when <求值表达式> then <表达式>-- when <求值表达式> then &...转载 2018-08-02 21:40:28 · 1226 阅读 · 1 评论 -
集合运算 union/except/intersect/inner join/right join
####################集合运算#######################################1.表的加法 union(增加的是记录 竖直方向) use xscj;CREATE TABLE Product2 (product_id CHAR(4) NOT NULL, product_name VARCHAR(100) NOT NULL...转载 2018-08-03 10:35:35 · 587 阅读 · 0 评论 -
sql自连接
https://blog.youkuaiyun.com/xiaoyaoyulinger/article/details/54175483转载 2018-08-18 08:40:59 · 1057 阅读 · 0 评论 -
test818
show databases;create database test818;use test818;-- 建表-- 学生表 create table Student( s_id varchar(20), s_name varchar(20) not null default '', s_birth varchar(20) not null default '', ...转载 2018-08-19 11:09:44 · 179 阅读 · 0 评论 -
MySQL练习题50
create database execise_new;use execise_new;-- 建表-- 学生表 create table Student( s_id varchar(20), s_name varchar(20) not null default '', s_birth varchar(20) not null default '', s_sex ...原创 2018-07-14 11:17:23 · 973 阅读 · 1 评论 -
流程控制语句Mysql
####################流程控制语句 -- 1.顺序控制语句 begin..end...delimiter //create function max1(i int,j int)returns intbegin return (select * from student where 学号=xh);end //delimiter ;-- 2.分支控制语句 ...转载 2018-07-13 21:21:50 · 266 阅读 · 0 评论 -
function
This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binarymysql的设置默认是不允许创建函数解决办法1:执行:SET GLOBAL log_bin_trust_function_creators = 1;不过 重启了 就失效了注意: 有主从复制的时候 从机必须要设...转载 2018-06-30 15:21:13 · 241 阅读 · 0 评论 -
MySQL 分组+子查询
########################第十三章 数据分组 #######################use test;show tables;##创建分组 group byselect vend_id,count(*) as num_prods from productsgroup by vend_id;select vend_id,count(*) as num...翻译 2018-07-02 20:00:03 · 1819 阅读 · 0 评论 -
mysql 15-16章联结
############################第十五章 联结表 #############################where创造联结select vend_name,prod_name,prod_price from vendors,productswhere vendors.vend_id=products.vend_idorder by vend_name,pr...翻译 2018-07-02 21:07:24 · 136 阅读 · 0 评论 -
mysql 4-9
#####################第四章 检索数据#####################show columns from products;#检索单个列 无序select prod_name from products;#检索多个列 select prod_id,prod_name,prod_price from products;#检索所有列 select * ...翻译 2018-07-02 21:58:06 · 301 阅读 · 0 评论 -
mysql 10-12
########################第10章 创建计算字段 #######################use test;select * from vendors;####拼接字段 concat把多个字符串拼接起来 ,串与串之间用逗号分隔 select concat(vend_name,' (',vend_country, ')') from vendorsorde...翻译 2018-07-02 21:58:55 · 259 阅读 · 0 评论 -
mysql 17-18
############################第十七章 组合查询 ##############################创建组合查询 ##union(重复的行自动取消)select vend_id,prod_id,prod_price from products where prod_price<=5unionselect vend_id,prod_id,pr...翻译 2018-07-04 16:17:34 · 137 阅读 · 0 评论 -
MySQL19-22
##########################第十九章 插入数据 ##############################插入完整的行 #null表示允许为空 notnull表示不能为空 #列的数目要保持一致 insert into customersvalues(null,'Pep E. LaPew','100 Main Street','Los Angeles','C...翻译 2018-07-04 20:14:45 · 185 阅读 · 0 评论 -
mySQL 23章存储过程
############################第23章 使用存储过程 #############################执行存储过程 call productpricing(@pricelow, @pricehigh, @priceaverage);##创建存储过程 delimiter...翻译 2018-07-04 21:14:42 · 194 阅读 · 0 评论 -
/group by/having/order by 常见错误
-- groupby子句常见错误 -- 1),SELECT 子句中只能存在以下三种 元素。-- ● 常数 ● 聚合函数 ● GROUP BY子句中指定的列名(也就是聚合键)#错误用法SELECT product_name, purchase_price, COUNT(*) -- 列名product_name不能包含FROM Product GROUP BY purchase_pri...转载 2018-07-17 21:57:13 · 1334 阅读 · 0 评论 -
null详解
-- null 的用法-- 1)希望选取NULL记录时,需要在条件表达式中使用IS NULL运算符。-- 希望选取不 是NULL的记录时,需要在条件表达式中使用IS NOT NULL运算符。#错误用法SELECT product_name, purchase_price FROM Product WHERE purchase_price = NULL;#正确用法SELECT p...转载 2018-07-17 21:58:00 · 1039 阅读 · 0 评论 -
insert用法小结
-- INSERT##1)对表进行全列 INSERT 时,可以省略表名后的列清单。 -- 这时 VALUES 子句的值会默认按照从左到右的顺序赋给每一列。##2)INSERT 语句中想给某一列赋予 NULL 值时,可以直接在 VALUES 子句的值清单中写入 NULL##3)显示方法插入默认值(建议显示)INSERT INTO ProductIns (product_id, pr...翻译 2018-07-18 15:48:28 · 11763 阅读 · 0 评论 -
修改表的结构 更新数据
#######修改表的结构 ##1.添加一条新的字段 alter table student add 专业 char(30); ##2.改变原有字段的数据类型 alter table course modify 学分 smallint; ##3.删除某一个字段 alter table student drop column 专业; #...翻译 2018-07-13 15:55:06 · 3475 阅读 · 0 评论 -
MySQL突然密码错误
管理工具---服务---MySQL---启动解决~原创 2018-07-13 16:18:23 · 3465 阅读 · 1 评论 -
注意事项:select格式,groupby 连接 子查询(MySQL)
#########select语句##1.基础格式 select 子句from 子句where 表达式group by 子句having 表达式order by 子句limit 子句union 操作符;##2.关于group by-- 特别注意:只有聚合函数和group by分组的字段才能出现在select语句中-- 出现聚合函数sum,avg,count之类的时候 ...原创 2018-07-13 16:55:55 · 2320 阅读 · 0 评论 -
Error Code: 1418. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declarat
创建函数时出现:Error Code: 1418. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_funct...转载 2018-07-13 21:02:33 · 2745 阅读 · 0 评论 -
anaconda 连接mysql
-----第一个驱动 http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python去这个网址下载放到文件夹scripts/new pkgs里面 cd C:\Anaconda3\Scripts\new pkgspip install mysqlclient-1.3.13-cp36-cp36m-win_amd64.whlpyth...转载 2018-11-02 16:15:16 · 6170 阅读 · 1 评论