oracle创建表空间,创建用户(转)
关键字: oracle 表空间 用户
//创建临时表空间
create temporary tablespace test_temp
tempfile 'E:/oracle/product/10.2.0/oradata/testserver/test_temp01.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
//创建数据表空间
create tablespace test_data
logging
datafile 'E:/oracle/product/10.2.0/oradata/testserver/test_data01.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local;
//创建用户并指定表空间
create user username identified by password
default tablespace test_data
temporary tablespace test_temp;
//给用户授予权限
grant connect,resource to username;
//以后以该用户登录,创建的任何数据库对象都属于test_temp 和test_data表空间,这就不用在每创建一个对象给其指定表空间了。
-----------------------------------------------
创建表:
用这个新建用户登录oracle,创建表:
用户表 ITS_USER
字段描述 |
字段名 |
类型 |
主键 |
不为空 |
备注 |
用户代码 |
USERXH |
VARCHAR2(32) |
TRUE |
TRUE |
|
用户姓名 |
USERNAME |
VARCHAR2(16) |
FALSE |
TRUE |
姓名 |
用户密码 |
PASSWORD |
VARCHAR2(32) |
FALSE |
FALSE |
用户密码 |
联系电话 |
TELEPHONE |
VARCHAR2(30) |
FALSE |
FALSE |
联系电话 |
管理部门 |
GLBM |
VARCHAR2(10) |
FALSE |
TRUE |
管理部门,its_departmnet.glbm |
用户等级 |
YHDJ |
VARCHAR2(2) |
FALSE |
TRUE |
|
用户角色 |
YHJS |
VARCHAR2(1) |
FALSE |
TRUE |
‘1’管理员,‘2’普通用户 |
CREATE TABLE ITS_USER
(USERXH VARCHAR2(32) NOT NULL,
USERNAME VARCHAR2(16),
PASSWORD VARCHAR2(32),
TELEPHONE VARCHAR2(30),
GLBM VARCHAR2(10),
YHDJ VARCHAR2(2),
YHJS VARCHAR2(1),
constraint PK_T_SCORE primary key(USERXH)
);
----------------------------------------------------------
查询:
select * from ITS_USER
-------------------------------------------------------
插入数据:
INSERT INTO ITS_USER(USERXH,USERNAME,PASSWORD,TELEPHONE,GLBM,YHDJ,YHJS)
VALUES('10001','王五','123456','123456789','省*厅','1','1');
VALUES('10002','李三','123456','123456789','市*局','2','2');
VALUES('10003','张林','123456','123456789','洪山*','1','1');
VALUES('10004','木工','123456','123456789','省*厅','4','2');
VALUES('10005','天天','123456','123456789','市*局','3','1');
VALUES('10006','胡三','123456','123456789','省*厅','5','2');
VALUES('10007','金鑫','123456','123456789','洪山*','6','1');
VALUES('10008','方大','123456','123456789','关山派出所','1','2');
-------------------------------------------------------
更新表字段:
UPDATE ITS_USER SET GLBM='1'
======================================
tomcat 连接查询oracle数据
<bean id="ITSUsrdataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@192.168.1.185:1521:demo</value>
</property>
<property name="username">
<value>marian</value>
</property>
<property name="password">
<value>marian</value>
</property>
<props>
<prop key="hibernate.dialect">
net.sf.hibernate.dialect.OracleDialect
</prop>
</props>
-----------------------------------------------
在其他oracle数据库上加添此数据库监听:
E:/oracle/product/10.1.0/Db_1/NETWORK/ADMIN/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.185)(PORT = 1521))
)
)
用PLsql登录OK