江苏城乡住房和城乡建设厅网站,网页游戏公益服,男女在床上做羞羞的事的网站,wordpress 添加登录界面文章目录如何创建表空间创建数据库创建用户的具体过程关于表空间的其它命令语句如何创建表空间
1、为什么要创建表空间#xff1f;
答#xff1a;在建立用户的时候#xff0c;我们建议数据库管理员要指定用户的默认表空间。因为我们在使用 Create 语句创建数据库对象…
文章目录如何创建表空间创建数据库创建用户的具体过程关于表空间的其它命令语句如何创建表空间
1、为什么要创建表空间
答在建立用户的时候我们建议数据库管理员要指定用户的默认表空间。因为我们在使用 Create 语句创建数据库对象如数据库表时候默认是存储在当前用户所属的表空间中。若不指定用户的默认表空间的话则用户每次创建数据库对象的时候都要指定表空间显然这并不是很合理。
另外要注意不同的表空间有不同的权限控制。用户对于表空间 A 具有完全控制权限可能对于表空间 B 就只有查询权限甚至连连接的权限的都没有。所以合理为用户配置表空间的访问权限也是提高数据库安全性的一个方法。
2、如何创建表空间
答创建示例
create tablespace tablecontrols
datafile C:\oracle\product\tablecontrols\tablecontrols.dbf
size 300M
autoextend on next 100M
maxsize unlimited
logging online permanent;说明 create tablespace创建表空间 tablecontrols表空间名称 datafile默认文件位置 size表空间大小 autoextend on next 100M自动扩展表空间100M当原始空间使用完时 maxsize unlimited无限制大小 logging online permanent永久在线记录
创建数据库
Oracle 安装完后其中有一个缺省的数据库除了这个缺省的数据库外我们还可以创建自己的数据库。对于初学者来说为了避免麻烦可以用 Database Configuration Assistant 向导来创建数据库。创建完数据库后并不能立即在数据库中建表必须先创建该数据库的用户并且为该用户指定表空间。
创建用户的具体过程
1.假如现在已经建好名为 news 的数据库此时在 F:/oracle/product/10.1.0/oradata/ 目录下已经存在 news 目录注意我的 Oracle10g 安装在 F:/oracle 下若你的 Oracle 安装在别的目录那么你新建的数据库目录就在 */product/10.1.0/oradata/ 目录下。
2.在创建用户之前先要创建表空间
其格式为格式: create 表空间名 datafile ‘数据文件名’ size 表空间大小。
如下所示
SQL create tablespace news_tablespace datafile F:/oracle/product/10.1.0/oradata/news/news_data.dbf size 500M;其中 news_tablespace 是你自定义的表空间名称可以任意取名F:/oracle/product/10.1.0/oradata/news/news_data.dbf 是数据文件的存放位置news_data.dbf 文件名也是任意取size 500M 是指定该数据文件的大小也就是表空间的大小。
3.现在建好了名为 news_tablespace 的表空间下面就可以创建用户了
格式为格式: create user 用户名 identified by 密码 default tablespace 表空间表。
如下所示
SQL create user news identified by news default tablespace news_tablespace;默认表空间 default tablespace 使用上面创建的表空间。
4.接着授权给新建的用户
SQL grant connect,resource to news; --表示把 connect,resource权限授予news用户
SQL grant dba to news; --表示把 dba权限授予给news用户关于表空间的其它命令语句
1、查询空闲表空间
select tablespace_name,file_id,block_id,bytes,blocks from dba_free_space;2、查询表空间的数据文件名称、大小和路径的信息
select tablespace_name,file_id,bytes,file_name from dba_data_files;3、修改数据文件大小
alter database datafile 需要增加的数据文件路径即上面查询出来的路径 resize 800M;4、创建表空间
create tablespace test datafile /home/app/oracle/oradata/oracle8i/test01.dbf size 8M autoextend on next 5M maxsize 10M; create tablespace sales datafile /home/app/oracle/oradata/oracle8i/sales01.dbf size 800M autoextend on next 50M maxsize unlimited maxsize //unlimited 是大小不受限制 create tablespace sales datafile /home/app/oracle/oradata/oracle8i/sales01.dbf size 800M autoextend on next 50M maxsize 1000M extent management local uniform; //unform表示区的大小相同默认为1M create tablespace sales datafile /home/app/oracle/oradata/oracle8i/sales01.dbf size 800M autoextend on next 50M maxsize 1000M extent management local uniform size 500K; //unform size 500K 表示区的大小相同为500K create tablespace sales datafile /home/app/oracle/oradata/oracle8i/sales01.dbf size 800M autoextend on next 50M maxsize 1000M extent management local autoallocate; //autoallocate表示区的大小由随表的大小自动动态改变大表使用大区小表使用小区 create tablespace sales datafile /home/app/oracle/oradata/oracle8i/sales01.dbf size 800M autoextend on next 50M maxsize 1000M temporary; //temporary创建字典管理临时表空间 create temporary tablespace sales tempfile /home/app/oracle/oradata/oracle8i/sales01.dbf size 800M autoextend on next 50M maxsize 1000M 创建本地管理临时表空间如果是临时表空间所有语句中的 datafile 都换为 tempfile系统默认创建字典管理临时表空间要创建本地管理临时表空间要加 temporary tablespace 关键字。创建本地管理临时表空间时不得使用 atuoallocate 参数系统默认使用 uniform 管理方式。
5、为表空间增加数据文件
alter tablespace sales add datafile /home/app/oracle/oradata/oracle8i/sales02.dbf size 800M autoextend on next 50M maxsize 1000M;6、更改自动扩展属性
alter database datafile /home/app/oracle/oradata/oracle8i/sales01.dbf, /home/app/oracle/oradata/oracle8i/sales02.dbf /home/app/oracle/oradata/oracle8i/sales01.dbf autoextend off;7、删除表空间
drop tablespace xxx including contents and datafiles