分页:
上一页 1 2 3 [4] 5 6 7 8 下一页
假设我们用ORACLE里举例用的scott用户,dept表。
①、用internal身份登录shenzhen数据库,创建scott用户并赋权
SQL>create user scott identified by tiger default tablespace users temporary tablespace temp;
SQL>grant connect, resource to scott;
SQL>grant execute on sys.dbms_defer to scott;
②、用scott身份登录shenzhen数据库,创建表dept
SQL>create table dept
(deptno number(2) primary key,
dname varchar2(14),
loc varchar2(13) );
③、如果数据库对象没有主关键字,可以运行以下SQL命令添加:
SQL>alter table dept add (constraint dept_deptno_pk primary key (deptno));
④、在shenzhen数据库scott用户下创建主关键字的序列号,范围避免和beijing的冲突。
SQL> create sequence dept_no increment by 1 start with 1 maxvalue 44 cycle nocache;
(说明:maxvalue 44可以根据应用程序及表结构主关键字定义的位数需要而定)
⑤、在shenzhen数据库scott用户下插入初始化数据
SQL>insert into dept values (dept_no.nextval,’accounting’,’new york’);
SQL>insert into dept values (dept_no.nextval,’research’,’dallas’);
SQL>commit;
⑥、在beijing数据库那边同样运行以上①,②,③
⑦、在beijing数据库scott用户下创建主关键字的序列号,范围避免和shenzhen的冲突。
SQL> create sequence dept_no increment by 1 start with 45 maxvalue 99 cycle nocache;
分页:
上一页 1 2 3 [4] 5 6 7 8 下一页