"ORA-00911: invalid character" - error while dropping or renaming tablespace due to junk chracters

The Problem

Not able to drop or rename a tablespace which is having junk characters in the name. For example:

SQL> alter tablespace ?[tablespace_name] rename to [tablespace_rename];
alter tablespace ?[tablespace_name] rename to [tablespace_rename]
  *
ERROR at line 1:
ORA-00911: invalid character
SQL> alter tablespace '?[tablespace_name]' rename to [tablespace_rename];
alter tablespace '?[tablespace_name]' rename to [tablespace_rename]
  *
ERROR at line 1:
ORA-02140: invalid tablespace name
SQL> alter tablespace "?[tablespace_name]" rename to [tablespace_rename];
alter tablespace "?[tablespace_name]" rename to [tablespace_rename]
*
ERROR at line 1:
ORA-00959: tablespace '?[tablespace_name]' does not exist

The Solution

The error is usually due to junk characters in the alter tablespace command. Use the UTF8 character set:

export NLS_LANG=AMERICAN_AMERICA.UTF8

Now the tablespace name is visible and you can issue the rename command.

SQL> alter tablespace "�[tablespace_rename]" rename to [tablespace_rename];