oracle学习笔记1——orcale相关操作——cmd中

版权声明:禁止copy抄袭,博主很凶的哦,超级凶的那种哦。 https://blog.csdn.net/Strawberry_595/article/details/82011206


解锁某个账户,cmd命令后,依次输入以下语句
sqlplus/nolog 
conn/as sysdba 
____________________________________________
alter user scott account unlock;
alter user scott identified by "tiger";
--------------------------------------------

表空间操作

drop tablespace scott_tablespace; -- 删除表空间,删之前可以先查看

create tablespace scott_tablespace
datafile 'D:\oraclexe\scott_tablespace.dbf'  	
size 512M					
autoextend on next 32M maxsize unlimited logging
extent management local				
segment space management auto;				

select * from user_tablespaces where tablespace_name='SCOTT_TABLESPACE';

用户相关操作

select * from all_users;

drop user scott cascade;

create user scott identified by "tiger" default tablespace scott_tablespace;

grant connect to scott;
revoke connect from scott;
grant resource to scott;
revoke resource from scott;



如果装的是简版,除了要添加SCOTT用户外,还需要手动导入该用户下的示范用表
相关语句如下:
CREATE TABLE DEPT (
  DEPTNO NUMBER(2) CONSTRAINT PK_DEPT PRIMARY KEY, 
	DNAME VARCHAR2(15),
	LOC VARCHAR2(60) 
);

CREATE TABLE EMP (
  EMPNO NUMBER(4) CONSTRAINT PK_EMP PRIMARY KEY,
	ENAME VARCHAR2(15),
	JOB VARCHAR2(9),
	MGR NUMBER(4),
	HIREDATE DATE,
	SAL NUMBER(7,2),
	COMM NUMBER(7,2),
	DEPTNO NUMBER(2) CONSTRAINT FK_DEPTNO REFERENCES DEPT
);

CREATE TABLE SALGRADE ( 
  GRADE NUMBER,
	LOSAL NUMBER,
	HISAL NUMBER 
);
-- 插入数据
-- 先插入主表DEPT数据
INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');

-- 插入员工表EMP数据
INSERT INTO EMP VALUES
(7369,'SMITH','CLERK',7902,to_date('17-12-1980','dd-mm-yyyy'),800,NULL,20);

-- 插入薪资等级表SALGRADE数据
INSERT INTO SALGRADE VALUES (1,700,1200);

-- 统一提交
commit;
-- 查看数据 自己写

猜你喜欢

转载自blog.csdn.net/Strawberry_595/article/details/82011206