唯一的字符串序列

——唯一的字符串序列 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)

);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值