The following steps are required to create a table in DB2 using AS and indicating the tablespace:
- Log in to DB2 using a valid user ID and password.
- Open a new command window or terminal session.
- Type the following command to create a new table:
CREATE TABLE newtablename AS (SELECT * FROM existingtablename)
- After the AS keyword, specify the tablespace where the new table will be stored. For example:
CREATE TABLE newtablename AS (SELECT * FROM existingtablename) TABLESPACE newtablespacename
- Press Enter to execute the command.
- Verify that the new table has been created by running a SELECT statement on the newtablename.