序列与索引
一、序列SEQUENCE、sequence
在sequence里面有两个方法
必须要先执行thomas.nextval然后执行 thomas.currval
从10-->20-->30-->40 ...........100
上面设置的是nocycle如果是设置的可循环的话就会循环
10-->20-->30-->40 ...........100-->10-->20-->30-->40 ...........100
不能前面都生成值了你再更改,比如前面都生成60、70了你再从1开始,每次加1也不合适呀
INSERT INTO thomas_AB VALUES(THOMAST.NEXTVAL,'AA',123)
INSERT INTO thomas_ABC VALUES(THOMAST.NEXTVAL,'BB',456)
假设上面的sequence从1开始每次加10,最大到100
你1、11、21 insert到 thomas_AB
然后31、41、51 insert到thomas_ABC
再然后61、71、81 insert到 thomas_AB
这样的话信息就断层了,多个表使用同一个序列,就是所谓的“裂缝”
二、索引
下面就是定义primary key 或者unique时就会自动创建索引
1.列中的范围很广:比如某员工的工资从0到几万,现在可以认为范围很广