达梦 storage 用法(一)
达梦 storage 用法
达梦(DM)是一种关系型数据库管理系统(DBMS),它包含了存储(storage)相关的一些重要功能。以下是一些针对达梦 storage 的用法及详细讲解:
1. 表空间 (Tablespace)
创建表空间:
create tablespace <tablespace_name> datafile '<file_path>' size <size>;
<tablespace_name>:表空间的名称。
<file_path>:存储表空间的文件路径。
<size>:表空间的大小。
修改表空间:
alter tablespace <tablespace_name>drop删除表 resize <size>;
<tablespace_name>:要修改的表空间的名称。
<size>:表空间的新大小。
删除表空间:
drop tablespace <tablespace_name>;
<tablespace_name>:要删除的表空间的名称。
2. 数据文件 (Datafile)
创建数据文件:
alter tablespace <tablespace_name> add datafile '<file_path>' size <size>;
<tablespace_name>:数据文件所属的表空间的名称。
<file_path>:数据文件的路径。
<size>:数据文件的大小。
修改数据文件大小:
alter database datafile '<file_path>' resize <size>;
<file_path>:要修改的数据文件的路径。
<size>:数据文件的新大小。
删除数据文件:
alter tablespace <tablespace_name> drop datafile '<file_path>';
<tablespace_name>:数据文件所属的表空间的名称。
<file_path>:要删除的数据文件的路径。
3. 扩展表空间 (Tablespace extension)
扩展表空间:
alter tablespace <tablespace_name> add datafile '<file_path>' size <size>;
<tablespace_name>:要扩展的表空间的名称。
<file_path>:新的数据文件路径。
<size>:扩展后的表空间大小。
4. 表空间备份与恢复 (Tablespace backup and restore)
备份表空间:
alter tablespace <tablespace_name> begin backup;
copy <file_path> to '<backup_path>';
alter tablespace <tablespace_name> end backup;
<tablespace_name>:要备份的表空间的名称。
<file_path>:需要备份的数据文件路径。
<backup_path>:备份文件的存储路径。
恢复表空间:
shutdown immediate;
copy '<backup_path>' to <file_path>;
startup;
<backup_path>:要恢复的备份文件路径。
<file_path>:要恢复的数据文件路径。
以上是达梦 storage 的一些常用用法,包括表空间的创建、修改和删除,数据文件的创建、修改和删除,表空间扩展以及表空间的备份与恢复。通过这些用法,您可以更好地管理和优化数据库的存储空间。