mysql

mysql之游标

北城以北 提交于 2021-02-17 01:06:04
先来个伪需求: 将表a的id和value加到一起组成一个新的值,然后在把这个值填入B表中; 表A 表B 要进行这样的操作必须的使用for循环,但是在mysql中的不是这样写,的需要游标这个东西; delimiter // create procedure p9() begin -- 声明变量 declare a_id int; declare a_value int ; declare num int ; declare done int default false; declare my_cursor cursor for select id,value1 from a;-- 建立游标 DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; -- 开始循环 open my_cursor; lhy:loop fetch my_cursor into a_id,a_value; if done=True then leave lhy;-- 离开循环 end if ; set num = a_id + a_value; insert into B(num) values(num); end loop lhy; -- 结束循环 close my_cursor; commit; end // delimiter; call p9();

docker,mysql,Navicat

北城以北 提交于 2021-02-17 01:02:00
Navicat破解网址 https://www.jianshu.com/p/5f693b4c9468 docker pull mysql docker run -d -p 3306:3306 --name mysql01 mysql/mysql-server docker logs mysql01 查看日志有默认密码 docker exec -it mysql01 bash 进入到容器里面 # mysql -uroot -p 默认是localhost,然后输入密码 use mysql 提示必须要改密码 修改用户密码 alter user 'root'@'localhost' identified by '123456'; SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password123'); select user,host from user //user表显示信息 改信息 mysql> CREATE USER 'Anker'@ 'localhost' IDENTIFIED BY 'pwd123456'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'Anker'@ 'localhost' WITH GRANT OPTION; mysql> CREATE USER 'Anker'@ '%'

MySQL事务

梦想与她 提交于 2021-02-16 23:07:44
原文链接 http://zhhll.icu/2021/01/02/%E6%95%B0%E6%8D%AE%E5%BA%93/%E5%85%B3%E7%B3%BB%E5%9E%8B%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E4%BA%8B%E5%8A%A1/ MySQL事务 事务:一个或一组SQL语句组成的一个执行单元,要么全部成功,要么全部失败。 注:mysql中只有innodb支持事务 事务的ACID特性 原子性(Atomicity) 指事务是一个不可分割的工作单位,事务中的操作要么都发生,要么都不发生 一致性(Consistency) 指事务必须使数据库从一个一致性状态变成另一个一致性状态 隔离性(Isolation) 指一个事务的执行不能被另一个事务干扰 持久性(Durability) 指事务一旦被提交,对数据库中数据的改变是永久性的 事务的创建 默认情况下mysql的事务是自动提交的 show variables like '%autocommit%'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | autocommit | ON | +---------------+-------+ #需要手动的禁用一下事务自动提交 set

服务器搭建个人网站(阿里云服务器)

天大地大妈咪最大 提交于 2021-02-16 22:03:06
服务器搭建个人网站 一丶购买服务器 这里我选的是 阿里云 服务器,进入 阿里云 官网 https://www.aliyun.com 阿里云 提供了几种服务器,云服务器ESC、轻量应用服务器,ESC更好一点儿,我选了轻量级应用服务器。购买好了之后,在 阿里云 网站主页→控制台→轻量应用服务器。找到运行中的实例点进去就好了。服务器器就购买好了 二、配置服务器环境 首先你要知道怎么把你本机的文件放到你的服务器里去:你在本机上复制文件,远程连接服务器(运行中敲“mstsc”可打开远程连接窗口),在服务器中粘贴即可,就这么简单。你也可以设置本机上的各个盘为共享也是OK的。其次千万要注意:要在 阿里云 服务器中把你的防火墙的端口打开比如8080,3306之类的,不打开你是访问不了的 (1)JDK和JRE 去官网 http://www.oracle.com/technetwork/java/javase/downloads/index.html 找到对应的JDK下载,或者百度“JDK”进入官网下载也是OK的,下载之后配置环境变量,此电脑→属性→高级系统设置→高级→环境变量→系统变量,新建JAVA_HOME和JRE_HOME两个变量,变量的值就是JDK和JRE的安装位置,配好之后再在path中加入JAVA_HOME和JRE_HOME,可以不用配classPath变量,新的jdk不建议配。 (2

What is the best datatype for storing URLs in a MySQL database?

非 Y 不嫁゛ 提交于 2021-02-16 21:33:34
问题 What is the best datatype for storing URLs in a MySQL database? The ideal would be something that doesn't take up a lot of space but can easily handle variable length URLs. 回答1: If by "links" you mean links to web pages, I'm guessing you want to store URLs. Since URLs are variable length strings the VARCHAR data type would seem the obvious choice. 回答2: You can store URLs as simple strings, but be careful when comparing values since URLs may come in various forms while actually representing

Search mysqli table with form and display results

老子叫甜甜 提交于 2021-02-16 21:30:56
问题 I'm searching a table with a form where the result could be from any of the 3 choices (cata, catb or catc) and then display the results, however my error warning keeps popping up and can't display the result? I'm stuck... <?php include("config.php"); $cata = $_POST['cata']; $catb = $_POST['catb']; $catc = $_POST['catc']; $query = "SELECT * FROM photos WHERE cata=? OR catb=? OR catc=?"; $conn = $db->prepare($query); $conn->bind_param("sss", $cata, $catb, $catc); if ($conn->execute()) { $result

Why MySQL completely reformat the VIEW query text?

空扰寡人 提交于 2021-02-16 21:08:37
问题 Using Firebird and SQL Server, when I create an VIEW the query text remain exactly as I wrote. No matter if I use SQLDBX, IbExpert, FlameRobin or SSMS, it extracts the same query text. But when it comes to MySQL, it COMPLETELY changes the query text. And when I extract it to a script, the carefully indented query text converts in a one BIG line of text. It's indifferent if using an ODBC application (SQLDBX) or MySQL WorkBench, it's absolutely annoying. After said that: There's some reasoning

Why MySQL completely reformat the VIEW query text?

为君一笑 提交于 2021-02-16 21:08:27
问题 Using Firebird and SQL Server, when I create an VIEW the query text remain exactly as I wrote. No matter if I use SQLDBX, IbExpert, FlameRobin or SSMS, it extracts the same query text. But when it comes to MySQL, it COMPLETELY changes the query text. And when I extract it to a script, the carefully indented query text converts in a one BIG line of text. It's indifferent if using an ODBC application (SQLDBX) or MySQL WorkBench, it's absolutely annoying. After said that: There's some reasoning

Why MySQL completely reformat the VIEW query text?

三世轮回 提交于 2021-02-16 21:07:18
问题 Using Firebird and SQL Server, when I create an VIEW the query text remain exactly as I wrote. No matter if I use SQLDBX, IbExpert, FlameRobin or SSMS, it extracts the same query text. But when it comes to MySQL, it COMPLETELY changes the query text. And when I extract it to a script, the carefully indented query text converts in a one BIG line of text. It's indifferent if using an ODBC application (SQLDBX) or MySQL WorkBench, it's absolutely annoying. After said that: There's some reasoning

Getting all children and subchildren from parent JPA

感情迁移 提交于 2021-02-16 20:55:09
问题 I have a table TABLE that can have parents of the same type. In Java the child can reach the parent but the parent doesn't have a list of children. In MySQL I was able to create the following query that gives me the children and subchildren of the parent, but I'm unable to translate this into JPA Java. How can I translate this query: SELECT * FROM TABLE AS T1 INNER JOIN (SELECT id FROM TABLE WHERE TABLE.parentId = 966) AS T2 ON T2.id = T1.parentId OR T1.parentId = 966 GROUP BY T1.id Into java