随笔分类 -  mysql数据库

摘要:MySQL数据库中提供了很丰富的函数。MySQL函数包括数学函数、字符串函数、日期和时间函数、条件判断函数、系统信息函数、加密函数、格式化函数等。通过这些函数,可以简化用户的操作。例如,字符串连接函数可以很方便的将多个字符串连接在一起。在这一讲中将讲解的内容包括:数学函数字符串函数日期和时间函数条件 阅读全文
posted @ 2020-06-10 21:36 马蹄哒哒 阅读(150) 评论(0) 推荐(0)
摘要:--创建触发器 delimiter //create trigger 触发器名 before(after) insert(update,delete) on t1 for each rowbegindeclare a varchar(20);declare b varchar(20);set a=( 阅读全文
posted @ 2020-06-10 21:33 马蹄哒哒 阅读(135) 评论(0) 推荐(0)
摘要:--创建视图(视图是虚拟存在的,不能向其中插入数据) create view 视图名 as select * from student; --修改视图 alter view 视图名 as sql语句; 阅读全文
posted @ 2020-06-10 21:09 马蹄哒哒 阅读(99) 评论(0) 推荐(0)
摘要:select * from 表名; select id,name as t(name这一列的新列名) from t1 where id>10 or name='王五'; select name,age,1 from t; select * from t where id in (1,5,12); s 阅读全文
posted @ 2020-06-10 20:59 马蹄哒哒 阅读(253) 评论(0) 推荐(0)
摘要:create table t1( id int, num1 int, num2 int, unique up (num1) /unique up (num1,num2) )engine=innodb default charset=utf8; 阅读全文
posted @ 2020-06-10 18:29 马蹄哒哒 阅读(399) 评论(0) 推荐(0)
摘要:--设置局部自增步长 set session auto_increment_increment=2; --设置全局自增步长 set global auto_increment_increment=2; --查看局部步长 show session variables like 'auto_inc%'; 阅读全文
posted @ 2020-06-10 18:24 马蹄哒哒 阅读(793) 评论(0) 推荐(0)
摘要:--创建主键 create table t1( nid int(11) not null auto_increment, pid int(11), num int(11), primary key(nid,pid) ) engine=innodb default charset=utf8; --创建 阅读全文
posted @ 2020-06-10 18:11 马蹄哒哒 阅读(314) 评论(0) 推荐(0)
摘要:-- 创建数据库 create database 数据库名 default charset =utf8; -- 创建表 create table 表名 ( id int,name char(20)); create table 表名 (id int null/not null,name char(2 阅读全文
posted @ 2020-06-09 20:00 马蹄哒哒 阅读(72) 评论(0) 推荐(0)
摘要:-- 创建用户 create user '用户名'@'ip地址' identified by 'password'; ip adress 可填%,即指可以在任何电脑上登录 -- 给用户进行授权 (一)grant 权限(select,insert,update) on 数据库名.表名 to '用户名' 阅读全文
posted @ 2020-06-09 19:59 马蹄哒哒 阅读(110) 评论(0) 推荐(0)