![](https://img-blog.csdnimg.cn/20190927151124774.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
Mysql/Mariadb
贪睡的蜗牛
记性不好,那就多写博客。。。。
展开
-
mysql常用命令行代码
为你的 MySQL 用户名。系统会提示你输入密码。为你要进入的数据库名称。为你要查看的表名称。为你要查询的表名称,原创 2023-12-02 22:09:50 · 432 阅读 · 0 评论 -
undefined reference to `mysql_init‘解决办法
使用宝塔安装的mysql数据库找到头文件在/www/server/mysql/include 实现在/www/server/mysql/lib 在c文件里面包含#include"mysql.h"进行编译 编译通过但是在运行的时候出现解决办法:输入mysql_config命令查看LIB依赖 --libs_r 后面便是需要添加的编译代码#include<stdlib.h>#include<stdio.h>#include<mysql/mysql.h原创 2021-05-20 15:36:05 · 8004 阅读 · 8 评论 -
游标的定义问题
create procedure p4()begindeclare row_cat_id int;declare row_cat_name varchar(90);declare row_parent_id int;declare cnt int default 0;//定义总行数declare i int default 0;declare getcategory cursor for select cat_id,cat_name,parent_id from category;selec原创 2021-08-07 18:36:28 · 112 阅读 · 0 评论 -
LAST_INSERT_ID()
mysql一个表中唯一ID生成就需要这个函数Last_insert_id()是MYSQL提供的返回当前客户端最后一个insert或update查询中设置为AUTO_INCREMENT列的值Last_insert_id()不受其他客户端影响,所以是线程安全的,当前客户端只能拿到当前客户端的最新值,不需加锁处理比如fileid是主键,并且设置成自动增加,那么在插入的时候不指定fileid,插入后通过LAST_INSERT_ID()就能得到插入最后一条记录的id,并且是当前线程执行的,并不需要事务控制i原创 2021-07-21 15:03:27 · 379 阅读 · 0 评论 -
mysql递归操作
1、新建表 create table `t_files` ( id int auto_increment, file_name varchar(100) default '', file_type tinyint(4) default 0, parent_id int null, update_time timestamp null, primary key(id), unique key(file_name, parent_id) );2、添加部分数据原创 2021-06-24 10:07:23 · 342 阅读 · 0 评论 -
mysql报错:You can‘t specify target table for update in FROM clause解决办法
运行delete from t_files where id in (select id from t_files where find_in_set(id, getChildLst(1)));报错:You can't specify target table for update in FROM clause。其含义:不能在同一表中查询的数据作为同一表的更新数据。那么新建一个虚表delete from t_files where id in (select id from .原创 2021-06-24 10:04:29 · 904 阅读 · 0 评论 -
mysql报错:You do not have the SUPER privilege and binary logging is enabled
解决方法1、用root用户登录:mysql -u root -p2、设置参数log_bin_trust_function_creators为1set global log_bin_trust_function_creators = 1;结果:原创 2021-06-24 09:40:02 · 4630 阅读 · 0 评论 -
数据库函数语法和控制结构
函数和存储过程比较类似1、存储过程可以有多个返回,比较适合做批量插入2、函数有且仅有一个返回,比较适合处理数据后返回一个结果语法create function 函数名(参数列表) returns 返回类型 #声明begin 函数体end使用delimiter 语句设置结束语句 delimiter $ 这里不能再加分号流程控制结构顺序结构:从上到下执行分支结构:选择一条去执行循环结构:在满足一定条件的基础上,重复执行...原创 2021-05-26 10:40:13 · 202 阅读 · 0 评论 -
数据库存储过程
存储过程和函数:类似于java中的方法好处:1、提高代码的重用性2、简化操作3、减少了编译次数并且减少了和数据库服务器的连接次数,提高了效率#存储过程含义:一组预先编译好的sql语句的集合,理解成批处理语句#一、创建语法create procedure 存储过程名 (参数列表)begin //begin就相当于大括号 存储过程体end注意:1、参数列表包含三部分参数模式、参数名、参数类型...原创 2021-05-24 14:36:48 · 225 阅读 · 1 评论