随笔分类 - db base
摘要:create table salary (userid int,salary decimal(9,2)); -- mysqlinsert into salary values(1,1000),(2,2000), (3,3000),(4,4000),(5,5000), (1,null),(2,500)
阅读全文
摘要:select * from emp where hiredate > '1982-1-1'; -- mysqlselect * from emp where hiredate > to_date('1982-1-1', 'yyyy-mm-dd'); -- oracle
阅读全文
摘要:本页面所有内容也可以在oracle 运行,只需要把int、float 、decimal 改为 number类型即可 -- 字符串转数字 int 类型 drop table test;create table test(id int);insert into test values(100);inse
阅读全文
摘要:-- 字符函数:-- 查询结果姓名小写 select lower(ename), sal, job from emp;-- 查询结果姓名大写 select upper(ename), sal, job from emp;-- 名字5个字符 select ename, sal, job from em
阅读全文
摘要:-- 内连接:-- 显示员工姓名、工资和公司所在地 select e.ename, e.sal, d.dname from emp e,dept d; -- 笛卡尔积 select e.ename, e.sal, d.dname from emp e join dept d; -- oracle语法
阅读全文
摘要:-- 工资高于3000的员工select * from emp where sal > 3000;-- 工资在2500和3000之间的员工select * from emp where sal <= 3000 and sal >= 2500;-- 指定日期后入职的员工select * from em
阅读全文
摘要:单列去重: mysql: drop table test;create table test(id int(4));insert into test values(1),(2),(3),(4),(1),(2);select count(distinct id) from test;oracle:dr
阅读全文
摘要:1、删除表结构和表数据 drop table 表名 [purge] purge表示不放入回收站 2、删除表数据 delete from 表名 [where ...] 特点:高水位线不降;记录日志,速度慢,可以恢复(savepoint test; rollback to test;) 3、删除表数据
阅读全文
摘要:打开已用时间set timing on;create table users(id number(20), name varchar2(20), password varchar2(20));insert into users values(111111111111111, '爱新觉罗·启星', '
阅读全文
摘要:1、mysql 有枚举类型,oracle 没有; mysql不支持number、varchar2类型,报错。2、oracle 支持全外连接,mysql 不支持 select e.ename, e.sal, d.dname from emp e full join dept d on e.deptno
阅读全文
摘要:InnoDB 以主键为索引组织数据;一个表不可以没有主键,如果不设主键,后台会自动生成并使用一个主键索引文件和数据文件是一个文件——即:一颗B+树非主键索引文件的叶子节点保存着主键支持事务和行锁 MyIsam
阅读全文
摘要:原子性:多个操作要么都成功,要么都失败,不可分隔。一致性:前面的操作成功了,后面的操作失败了,要回滚,保证数据一致性。隔离性:多个事务之间互不影响。持久性:一旦提交,不可逆
阅读全文
摘要:select ename employee.name from emp; 在数据库查询时,如果列名的别名里特殊符号,报错。 select ename 'employee.name' from emp; -- 单引号 select ename `employee.name` from emp;-- 反
阅读全文
摘要:1、通过分隔符可以将其中的内容作为一个整体的字符串进行处理。 假设数据库中有一个表,名为user info,注意这个名字,user 和 info 中间存在一个空格。 如果直接写如下查询,会报错,可能会提示 user 表不存在或者 user 附近有语法错误。 select * from user in
阅读全文
摘要:1、单行注释 “-- ” 即:两个中滑线加一个空格 2、多行注释 "/* ... */" 示例: -- 单行注释 /* 多行注释*/ create table test(id int); 这三行代码在mysql 中,oracle 中都可以执行。
阅读全文
摘要:1、mysql下建表及插入数据 /* Navicat MySQL Data Transfer Source Server : mysql Source Server Version : 50640 Source Host : localhost:3306 Source Database : test
阅读全文

浙公网安备 33010602011771号