——唯一的字符串序列 32位 可以用来做主键
Select sys_guid() from dual; 序列字符串
伪列:nextval、currval
创建表
Create table test192(
Id number(10),
Name varchar2(50)
);
查询表
Select *from test192;
插入数据
insert into test192 values(1,’掌声’);
在原表前加一序列
Select sys-guid (),id, name from test192;
———sys_guid() 伪列
Select sys-guid (), t . * from test192 t;
—-添加约束
Select 1+2 from dual;
Select *from rj192;
———序列 sequence
——作用:实现主键自增
——特点: 唯一 但可能不连续
—-默认初始值是0 调用nextval增加1
—-创建序列
Create sequence seq_rj192;
调用序列数
Insert into rj192(id, name, age,salary) values(seq_rj192.nextval,’李四’,20,3546.984);
查询当前序列值
Select seq_rj192.curval from dual;
———删除一条数据
Delete from rj192 where id=1;
———行号 rownum 重要!!
——实现分页
——每页2条,显示第2页
———mysql 分页 limit 起始行,2 (从第几条开始,查几条)
—-limit 2,2 起始行 0
起始行:(当前页-1) * 每页大小
limit 2,2
———oracle
——每页x条,显示第y页 页面大小、当前页码
——对应页的,上一页的末尾行号,下一页的开始行号
Select * from(
//查询表rj192的行号
Select rownum rn, r . * from rj192 r // 子查询
)where rn>2 and rn<5; //2为起始行号,5为结束行号
——-推荐上方方式
—-5 x*y+1 即 当前页 * 页面大小 + 1
—-2 (y-1)*x 即(当前页-1)* 页面大小
Select * from(
//查询表rj192的行号
Select rownum rn, r . * from rj192 r // 子查询
)where rn<5 and rn>2;
———rowid 每条记录的物理位置
Select rowid , r . * from rj192 r;
——使用jdbc连接数据库
Select * from user_tables;
Create table test1(
id number(10)
);