Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creation of Schema in Oracle after checking

EV259Apr 22 2013 — edited Apr 22 2013
All,

My sincere apologies to post this here, but I did not find the answer anywhere.

I have a task to convert some SQL Server Scripts to Oracle.

The below is the sql server script to create the schema called HRMS after checking whether it is existing or not.

------

IF NOT EXISTS (SELECT [schema_id] FROM [sys].[schemas] WHERE [name] = N'HRMS')
BEGIN
EXECUTE ('CREATE SCHEMA [HRMS] AUTHORIZATION [dbo];');
END

GO

------------------
Can we have any similar kind of solution / statement in oracle. Please help me.

When I read in the Oracle Docs, CREATE SCHEMA statement is just to bundle multiple sql statements to a single transaction.

http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_6014.htm


2)
-----------------
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[HRMS].[TBL_PMappingAND type in (N'U'))
DROP TABLE [HRMS].[TBL_PMapping]
GO
-----------------

This statement is to check whether the table called 'TBL_PMapping is exists or not and, if exists then drop it. Please suggest me a similar approach/ how to achieve the same with in Oracle.

First need to check whether the table exists or not, if exists then drop it other wise create it.

I would request for your kind help in this. Thank you very much in advance.

Thanks,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 20 2013
Added on Apr 22 2013
4 comments
390 views