Creating an index in a temporary tablespace
Tables and indexes are created in users tablespace, which is USERS by default. A temporary tablespace, TEMP by default, is used by oracle for sorting large amount of data on disk. Temporary tablespace is typically used for processing joins, order by or creating indexes. 

Since the default tablespace TEMP is not large enough for creating a large index, your example creates a large temporary tablespace ts_tmp for the index creation purpose only and drops it afterwards. 

When creating the index with CREATE UNIQUE INDEX ... TABLESPACE ... command, don't use ts_tmp  in the TABLESPACE clause. This will give you Attempt to create PERMANENT object in a TEMPORARY tablespace error. 

Either don't use the TABLESPACE clause, then the defualt users tablespace will be used. Or give a tablespace name that was created with a CREATE TABLESPACE command.