How do you create a tablespace in sqlplus?
To create a tablespace in SQL*Plus, you can follow these steps:
- Open the SQL*Plus command-line interface.
- Log in to your database using the sys user. Enter the following command and press the Enter key:
sqlplus sys as sysdba
- Enter the password for the sys user and press Enter to log in to the database.
- Create a table space using the following syntax:
CREATE TABLESPACE tablespace_name
DATAFILE 'path_to_datafile' SIZE file_size;
tablespace_name represents the name of the tablespace, path_to_datafile indicates the path and name of the data file, and file_size corresponds to the size of the data file. You can modify these values as needed.
- After executing the CREATE TABLESPACE statement above, a new tablespace will be created.
- You can use the following command to confirm if the table space has been successfully created:
SELECT tablespace_name FROM dba_tablespaces;
This will list all the tablespaces that have been created.
- If you no longer need a specific table space, you can use the following syntax to delete it:
DROP TABLESPACE tablespace_name INCLUDING CONTENTS;
In this case, tablespace_name is the name of the tablespace to be deleted.
Please note that creating and deleting tablespaces requires appropriate permissions. Make sure you have sufficient permissions to perform these actions.