Creating An Oracle User If It Doesn't Already Exist
Answer : The IF NOT EXISTS syntax available in SQL Server, is not available in Oracle. In general, Oracle scripts simply execute the CREATE statement, and if the object already exist, you'll get an error indicating that, which you can ignore. This is what all the standard Oracle deployment scripts do. However, if you really want to check for existence, and only execute if object doesn't exist, thereby avoiding the error, you can code a PL/SQL block. Write a SQL that checks for user existence, and if it doesn't exist, use EXECUTE IMMEDIATE to do CREATE USER from the PL/SQL block. An example of such a PL/SQL block might be: declare userexist integer; begin select count(*) into userexist from dba_users where username='SMITH'; if (userexist = 0) then execute immediate 'create user smith identified by smith'; end if; end; / You need to write a pl/sql block. See an example here You can check if the user exists in the all_users table using som...