本文主要是介绍创建数据库表空间、表及用户,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.创建数据库表空间:
登录数据库:
oracle@linux:~> sqlplus / as sysdba;
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Sep 5 14:17:49 2016
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
创建表空间
SQL> create tablespace zxin_data
2 logging
3 datafile '/home/oracle/oradata/zxin/zxin_data.dbf'
4 size 2048M
5 autoextend on
6 next 50M maxsize 3072M
7 extent management local;
Tablespace created.
SQL>
创建临时表空间
SQL> create temporary tablespace zxin_temp
2 tempfile '/home/oracle/oradata/zxin/zxin_temp.dbf'
3 size 1024M
4 autoextend on
5 next 20M maxsize 1024M
6 extent management local;
Tablespace created.
SQL>
2.创建数据库用户,并指定表空间及临时表空间:
SQL> create user zxdbp_test identified by zxdbp_test
2 default tablespace zxin_data
3 temporary tablespace zxin_temp;
User created.
SQL>
3.建表:
首先给刚建的用户zxdbp_test赋予一个权限,然后用它建表:
SQL> grant dba to zxdbp_test;
Grant succeeded.
SQL>
SQL> create table test(id varchar2(20) not null,name varchar2(16),address varchar2(24));
Table created.
SQL>
查看一下表结构是否与我们建表时的一致:
SQL> desc test;
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL VARCHAR2(20)
NAME VARCHAR2(16)
ADDRESS VARCHAR2(24)
SQL>
插入一条记录:
SQL> insert into test(id,name,address) values('20160905001','Chong Khaifoo','Malaysia Kualalumpur');
1 row created.
SQL> select * from test;
ID NAME ADDRESS
-------------------- ---------------- ------------------------
20160905001 Chong Khaifoo Malaysia Kualalumpur
SQL>
这篇关于创建数据库表空间、表及用户的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!