- 论坛徽章:
- 0
|
select * from user_ts_quotas;
select * from user_users;
create table emp (
empno number(7),
ename varchar2(20),
sal number(7,2),
depno number(4)
)
insert into emp values (1001,'GARY',2000,10);
commit;
create table emp1 as select * from emp;
alter table emp add (hire_date date);
alter table emp modify (sal number(10,2));
alter table emp rename column sal to salary
alter table emp drop column salary;
rename emp to employees;
create table dept (
deptno number(4) ,
dname varchar2(20) not null,
loc varchar2(20),
constraint dept_pk primary key (deptno)
insert into dept values(20,'hr','gz');
create table emp (
empno number(7),
ename varchar2(20) not null,
email varchar2(50),
sal number(7,2),
deptno number(2),
constraint emp_pk primary key (empno),
constraint emp_email_uk unique (email),
constraint emp_dep_fk foreign key (deptno) references dept(deptno),
constraint emp_sal_ck check(sal >=0)
)
alter table emp modify (sal not null);
alter table emp drop constraint emp_sal_ck;
select * from user_constraints where table_name='EMP'
ALTER TABLE DEPT MOVE;
ALTER TABLE DEPT MOVE TABLESPACE USERS;
create index emp_sal_idx on emp(sal);
create index emp_dept_sal on emp(deptno,sal);
ALTER TABLE DEPT ENABLE ROW MOVEMENT;
ALTER TABLE DEPT SHRINK SPACE;
create index emp_ename_idx on emp(upper(ename));
select * from user_indexes where table_name='EMP';
select * from user_ind_columns where table_name='EMP';
DROP INDEX EMP_DEPT_SAL;
ALTER INDEX EMP_EMAIL_UK COALESCE;
ALTER INDEX EMP_EMAIL_UK REBUILD TABLESPACE USERS;
CREATE BITMAP INDEX EMP_DEPT_IDX ON EMP(DEPTNO);
create or replace view emp_view_10 as
select * from emp where deptno=10
create or replace view emp_view_s
as
select deptno,count(*) c,avg(sal) a
from emp group by deptno
create or replace view emp_view_s
as
select deptno,count(*) c,avg(sal) a
from emp group by deptno
with read only;
select view_name,text from user_views;
grant create sequence to gary;
create sequence my_seq_1 start with 10 increment by 2 maxvalue 5000 ;
select my_seq_1.nextval from dual;
select my_seq_1.currval from dual;
insert into emp values(my_seq_1.nextval,'gary',
'garywei'||my_seq_1.currval,1000,10)
/
select * from user_sequences;
grant create synonym to gary;
create synonym employees for emp;
grant select on emp to wei;
create synonym emp for gary.emp;
select * from user_synonyms;
grant create public synonym to gary;
grant drop public synonym to gary;
create public synonym emp for emp;
select * from all_synonyms where synonym_name='EMP';
lsnrctl status
lsnrctl start
lsnrctl stop
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=CWGZT200-03)(PORT=1526)))';
alter system register;
alter system set service_names=mydb,mydb1; |
|