diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/default/create.sql
index b85760d1..24537c8c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/default/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/default/create.sql
@@ -2,9 +2,9 @@
 {% import 'macros/privilege.macros' as PRIVILEGE %}
 {% import 'macros/security.macros' as SECLABEL %}
 {% if data.is_template %}
-CREATE LANGUAGE {{ conn|qtIdent(data.name) }};
+CREATE OR REPLACE LANGUAGE {{ conn|qtIdent(data.name) }};
 {% else %}
-CREATE{% if data.trusted %} TRUSTED{% endif %} PROCEDURAL LANGUAGE {{ conn|qtIdent(data.name) }}
+CREATE OR REPLACE{% if data.trusted %} TRUSTED{% endif %} PROCEDURAL LANGUAGE {{ conn|qtIdent(data.name) }}
 {% if data.lanproc %}
     HANDLER {{ conn|qtIdent(data.lanproc) }}
 {% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/tests/pg/9.4_plus/create_trusted_language_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/tests/pg/9.4_plus/create_trusted_language_msql.sql
index f4716a8e..323611cf 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/languages/tests/pg/9.4_plus/create_trusted_language_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/languages/tests/pg/9.4_plus/create_trusted_language_msql.sql
@@ -1,4 +1,4 @@
-CREATE TRUSTED PROCEDURAL LANGUAGE "Lan1_$%{}[]()&*^!@""'`\/#"
+CREATE OR REPLACE TRUSTED PROCEDURAL LANGUAGE "Lan1_$%{}[]()&*^!@""'`\/#"
     HANDLER plpgsql_call_handler
     INLINE plpgsql_inline_handler
     VALIDATOR plpgsql_validator
diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/tests/pg/9.4_plus/create_untrusted_language_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/tests/pg/9.4_plus/create_untrusted_language_msql.sql
index 7680de54..17e3eb4d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/languages/tests/pg/9.4_plus/create_untrusted_language_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/languages/tests/pg/9.4_plus/create_untrusted_language_msql.sql
@@ -1,4 +1,4 @@
-CREATE PROCEDURAL LANGUAGE "Lan1_$%{}[]()&*^!@""'`\/#"
+CREATE OR REPLACE PROCEDURAL LANGUAGE "Lan1_$%{}[]()&*^!@""'`\/#"
     HANDLER plpgsql_call_handler
     INLINE plpgsql_inline_handler
     VALIDATOR plpgsql_validator
diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/tests/ppas/9.4_plus/create_trusted_language_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/tests/ppas/9.4_plus/create_trusted_language_msql.sql
index f4716a8e..323611cf 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/languages/tests/ppas/9.4_plus/create_trusted_language_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/languages/tests/ppas/9.4_plus/create_trusted_language_msql.sql
@@ -1,4 +1,4 @@
-CREATE TRUSTED PROCEDURAL LANGUAGE "Lan1_$%{}[]()&*^!@""'`\/#"
+CREATE OR REPLACE TRUSTED PROCEDURAL LANGUAGE "Lan1_$%{}[]()&*^!@""'`\/#"
     HANDLER plpgsql_call_handler
     INLINE plpgsql_inline_handler
     VALIDATOR plpgsql_validator
diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/tests/ppas/9.4_plus/create_untrusted_language_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/tests/ppas/9.4_plus/create_untrusted_language_msql.sql
index 7680de54..17e3eb4d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/languages/tests/ppas/9.4_plus/create_untrusted_language_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/languages/tests/ppas/9.4_plus/create_untrusted_language_msql.sql
@@ -1,4 +1,4 @@
-CREATE PROCEDURAL LANGUAGE "Lan1_$%{}[]()&*^!@""'`\/#"
+CREATE OR REPLACE PROCEDURAL LANGUAGE "Lan1_$%{}[]()&*^!@""'`\/#"
     HANDLER plpgsql_call_handler
     INLINE plpgsql_inline_handler
     VALIDATOR plpgsql_validator
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate.sql
index 5401aa23..20815da3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate.sql
@@ -7,7 +7,11 @@ CREATE TABLE IF NOT EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'
     id integer,
     status text COLLATE pg_catalog."default",
     arr numeric
-) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops);
+) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops)
+WITH (
+    OIDS = FALSE
+)
+TABLESPACE pg_default;
 
 ALTER TABLE IF EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
     OWNER to postgres;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate_msql.sql
index 55f9b7cd..2de617d6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate_msql.sql
@@ -3,7 +3,10 @@ CREATE TABLE IF NOT EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'
     id integer,
     status text,
     arr numeric
-) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops);
+) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops)
+WITH (
+    OIDS = FALSE
+);
 
 ALTER TABLE IF EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
     OWNER to postgres;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/create_partition_table_with_collate.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/create_partition_table_with_collate.sql
index 5401aa23..20815da3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/create_partition_table_with_collate.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/create_partition_table_with_collate.sql
@@ -7,7 +7,11 @@ CREATE TABLE IF NOT EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'
     id integer,
     status text COLLATE pg_catalog."default",
     arr numeric
-) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops);
+) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops)
+WITH (
+    OIDS = FALSE
+)
+TABLESPACE pg_default;
 
 ALTER TABLE IF EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
     OWNER to postgres;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/create_partition_table_with_collate_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/create_partition_table_with_collate_msql.sql
index b0b3a820..2de617d6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/create_partition_table_with_collate_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/create_partition_table_with_collate_msql.sql
@@ -1,9 +1,12 @@
 CREATE TABLE IF NOT EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
 (
     id integer,
-    status text COLLATE pg_catalog."default",
+    status text,
     arr numeric
-) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops);
+) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops)
+WITH (
+    OIDS = FALSE
+);
 
 ALTER TABLE IF EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
     OWNER to postgres;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/test.json
index 0bb9809d..809b147d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/test.json
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/test.json
@@ -1949,7 +1949,7 @@
       "msql_endpoint": "NODE-table.msql",
       "data": {
         "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#",
-        "relowner": "enterprisedb",
+        "relowner": "postgres",
         "relacl": [],
         "description": "partition table",
         "coll_inherits": "[]",
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate.sql
index 158d9a6a..5b100df7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate.sql
@@ -7,7 +7,11 @@ CREATE TABLE IF NOT EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'
     id integer,
     status text COLLATE pg_catalog."default",
     arr numeric
-) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops);
+) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops)
+WITH (
+    OIDS = FALSE
+)
+TABLESPACE pg_default;
 
 ALTER TABLE IF EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
     OWNER to enterprisedb;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate_msql.sql
index aa10397b..67eb01fb 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate_msql.sql
@@ -3,7 +3,10 @@ CREATE TABLE IF NOT EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'
     id integer,
     status text,
     arr numeric
-) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops);
+) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops)
+WITH (
+    OIDS = FALSE
+);
 
 ALTER TABLE IF EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
     OWNER to enterprisedb;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/create_partition_table_with_collate.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/create_partition_table_with_collate.sql
index 158d9a6a..5b100df7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/create_partition_table_with_collate.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/create_partition_table_with_collate.sql
@@ -7,7 +7,11 @@ CREATE TABLE IF NOT EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'
     id integer,
     status text COLLATE pg_catalog."default",
     arr numeric
-) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops);
+) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops)
+WITH (
+    OIDS = FALSE
+)
+TABLESPACE pg_default;
 
 ALTER TABLE IF EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
     OWNER to enterprisedb;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/create_partition_table_with_collate_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/create_partition_table_with_collate_msql.sql
index aa10397b..67eb01fb 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/create_partition_table_with_collate_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/create_partition_table_with_collate_msql.sql
@@ -3,7 +3,10 @@ CREATE TABLE IF NOT EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'
     id integer,
     status text,
     arr numeric
-) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops);
+) PARTITION BY RANGE (status COLLATE "C" text_pattern_ops)
+WITH (
+    OIDS = FALSE
+);
 
 ALTER TABLE IF EXISTS public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
     OWNER to enterprisedb;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/create.sql
index 2016209b..7f3ec587 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/create.sql
@@ -2,7 +2,7 @@
 {% import 'macros/privilege.macros' as PRIVILEGE %}
 {% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
 {% if data.name %}
-CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
+CREATE SCHEMA IF NOT EXISTS {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
 
     AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %};
 {#  Alter the comment/description #}
@@ -37,4 +37,4 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
 
 {{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
 {% endfor %}
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/delete.sql
index 74e9126d..75e9a8b4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/delete.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/delete.sql
@@ -1 +1 @@
-DROP SCHEMA {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%};
+DROP SCHEMA IF EXISTS {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%};
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/create.sql
index 4a071c4b..ccddea9e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/create.sql
@@ -2,7 +2,7 @@
 {% import 'macros/privilege.macros' as PRIVILEGE %}
 {% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
 {% if data.name %}
-CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
+CREATE SCHEMA IF NOT EXISTS {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
 
     AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %};
 {#  Alter the comment/description #}
@@ -37,4 +37,4 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
 
 {{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
 {% endfor %}
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/delete.sql
index 74e9126d..75e9a8b4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/delete.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/delete.sql
@@ -1 +1 @@
-DROP SCHEMA {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%};
+DROP SCHEMA IF EXISTS {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%};
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/create.sql
index 4a071c4b..ccddea9e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/create.sql
@@ -2,7 +2,7 @@
 {% import 'macros/privilege.macros' as PRIVILEGE %}
 {% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
 {% if data.name %}
-CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
+CREATE SCHEMA IF NOT EXISTS {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
 
     AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %};
 {#  Alter the comment/description #}
@@ -37,4 +37,4 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
 
 {{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
 {% endfor %}
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/delete.sql
index 74e9126d..75e9a8b4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/delete.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/delete.sql
@@ -1 +1 @@
-DROP SCHEMA {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%};
+DROP SCHEMA IF EXISTS {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%};
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/create.sql
index 2016209b..7f3ec587 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/create.sql
@@ -2,7 +2,7 @@
 {% import 'macros/privilege.macros' as PRIVILEGE %}
 {% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
 {% if data.name %}
-CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
+CREATE SCHEMA IF NOT EXISTS {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
 
     AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %};
 {#  Alter the comment/description #}
@@ -37,4 +37,4 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
 
 {{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
 {% endfor %}
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/delete.sql
index 74e9126d..75e9a8b4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/delete.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/delete.sql
@@ -1 +1 @@
-DROP SCHEMA {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%};
+DROP SCHEMA IF EXISTS {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%};
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_add_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_add_priv.sql
index e90ef0f7..82ad3b78 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_add_priv.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_add_priv.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION postgres;
 
 GRANT CREATE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql
index e42962c2..1cc63866 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION postgres;
 
 GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_name.sql
index 86bf07af..3642167e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_name.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_name.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema1_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema1_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema1_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION postgres;
 
 COMMENT ON SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#"
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql
index c8fc71a7..5b58e2c6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION postgres;
 
 GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options.sql
index 9251fbe0..83612440 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION postgres;
 
 COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options_msql.sql
index 2c80b514..d03bb981 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options_msql.sql
@@ -1,4 +1,4 @@
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#";
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#";
 
 COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
     IS 'This is a test comment';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment.sql
index 83973a3a..e0e4cf4c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION postgres;
 
 COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment_msql.sql
index add17f78..ce2bbc2a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment_msql.sql
@@ -1,4 +1,4 @@
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#";
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#";
 
 COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
     IS 'This is a test comment';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_add_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_add_priv.sql
index 8b130b32..bd5e39ff 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_add_priv.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_add_priv.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION enterprisedb;
 
 GRANT CREATE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql
index a18430f2..f74bbabd 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION enterprisedb;
 
 GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_name.sql
index 5ef0e452..3b195c25 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_name.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_name.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema1_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema1_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema1_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION enterprisedb;
 
 COMMENT ON SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#"
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql
index e200bff3..33060693 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION enterprisedb;
 
 GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options.sql
index 5b92773e..bb7da31f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION enterprisedb;
 
 COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options_msql.sql
index 2c80b514..d03bb981 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options_msql.sql
@@ -1,4 +1,4 @@
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#";
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#";
 
 COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
     IS 'This is a test comment';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment.sql
index c8a8a15b..bc7dcd5a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment.sql
@@ -1,8 +1,8 @@
 -- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
 
--- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
+-- DROP SCHEMA IF EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#" ;
 
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#"
     AUTHORIZATION enterprisedb;
 
 COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment_msql.sql
index add17f78..ce2bbc2a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment_msql.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment_msql.sql
@@ -1,4 +1,4 @@
-CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#";
+CREATE SCHEMA IF NOT EXISTS "test_schema_$%{}[]()&*^!@""""'`\/#";
 
 COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
     IS 'This is a test comment';
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/sql/default/create.sql
index cf2eada9..5c2bbbff 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/sql/default/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/sql/default/create.sql
@@ -1,10 +1,10 @@
 {% if display_comments %}
 -- RESOURCE GROUP: {{rgname}}
 
--- DROP RESOURCE GROUP {{ conn|qtIdent(rgname) }}
+-- DROP RESOURCE GROUP IF EXISTS {{ conn|qtIdent(rgname) }}
 
 {% endif %}
 {# ============= Create the resource group============= #}
 {% if rgname %}
 CREATE RESOURCE GROUP {{ conn|qtIdent(rgname) }};
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/sql/default/delete.sql b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/sql/default/delete.sql
index 1c9bda7b..ee9a38d4 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/sql/default/delete.sql
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/sql/default/delete.sql
@@ -4,5 +4,5 @@ SELECT rgrpname FROM edb_resource_group WHERE oid = {{rgid}}::oid;
 {% endif %}
 {# ============= Below SQL will drop the resource group ============= #}
 {% if rgname %}
-DROP RESOURCE GROUP {{ conn|qtIdent(rgname) }};
-{% endif %}
\ No newline at end of file
+DROP RESOURCE GROUP IF EXISTS {{ conn|qtIdent(rgname) }};
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/alter_resource_group_name.sql b/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/alter_resource_group_name.sql
index 2a053a53..df5ecc1c 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/alter_resource_group_name.sql
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/alter_resource_group_name.sql
@@ -1,6 +1,6 @@
 -- RESOURCE GROUP: Rg2_$%{}[]()&*^!@"'`\/#
 
--- DROP RESOURCE GROUP "Rg2_$%{}[]()&*^!@""'`\/#"
+-- DROP RESOURCE GROUP IF EXISTS "Rg2_$%{}[]()&*^!@""'`\/#"
 
 CREATE RESOURCE GROUP "Rg2_$%{}[]()&*^!@""'`\/#";
 
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/alter_resource_group_options.sql b/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/alter_resource_group_options.sql
index d64aea6a..57147139 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/alter_resource_group_options.sql
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/alter_resource_group_options.sql
@@ -1,6 +1,6 @@
 -- RESOURCE GROUP: Rg2_$%{}[]()&*^!@"'`\/#
 
--- DROP RESOURCE GROUP "Rg2_$%{}[]()&*^!@""'`\/#"
+-- DROP RESOURCE GROUP IF EXISTS "Rg2_$%{}[]()&*^!@""'`\/#"
 
 CREATE RESOURCE GROUP "Rg2_$%{}[]()&*^!@""'`\/#";
 
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/create_resource_group.sql b/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/create_resource_group.sql
index a0f5f191..43a70238 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/create_resource_group.sql
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/tests/ppas/9.4_plus/create_resource_group.sql
@@ -1,6 +1,6 @@
 -- RESOURCE GROUP: Rg1_$%{}[]()&*^!@"'`\/#
 
--- DROP RESOURCE GROUP "Rg1_$%{}[]()&*^!@""'`\/#"
+-- DROP RESOURCE GROUP IF EXISTS "Rg1_$%{}[]()&*^!@""'`\/#"
 
 CREATE RESOURCE GROUP "Rg1_$%{}[]()&*^!@""'`\/#";
 
diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/sql.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/sql.sql
index 9691aa80..0d255971 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/sql.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/sql.sql
@@ -4,7 +4,7 @@ FROM
 (SELECT
 	    '-- Role: '	||
 		pg_catalog.quote_ident(rolname) ||
-		E'\n-- DROP ROLE ' ||
+		E'\n-- DROP ROLE IF EXISTS ' ||
 		pg_catalog.quote_ident(rolname) || E';\n\nCREATE ROLE ' ||
 		pg_catalog.quote_ident(rolname) || E' WITH\n  ' ||
 		CASE WHEN rolcanlogin THEN 'LOGIN' ELSE 'NOLOGIN' END || E'\n  ' ||
diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/sql.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/sql.sql
index ca81e7fa..c64b5633 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/sql.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/sql.sql
@@ -4,7 +4,7 @@ FROM
 (SELECT
 	    '-- Role: ' ||
 		pg_catalog.quote_ident(rolname) ||
-		E'\n-- DROP ROLE ' ||
+		E'\n-- DROP ROLE IF EXISTS ' ||
 		pg_catalog.quote_ident(rolname) || E';\n\nCREATE ROLE ' ||
 		pg_catalog.quote_ident(rolname) || E' WITH\n  ' ||
 		CASE WHEN rolcanlogin THEN 'LOGIN' ELSE 'NOLOGIN' END || E'\n  ' ||
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.sql
index 5cb6cf67..c2e3d46c 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.sql
@@ -1,5 +1,5 @@
 -- Role: "Role1_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
   LOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.sql
index c140f044..4ec6c0f9 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   LOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.sql
index 046d0691..3d8db5d2 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   LOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_description.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_description.sql
index ff2e6620..c3998071 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_description.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_description.sql
@@ -1,5 +1,5 @@
 -- Role: "Role1_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_name.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_name.sql
index 5c757fc9..16fb4471 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_name.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_name.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.sql
index fb8b74a7..5a0d12df 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.sql
index 1b9a2979..478dec60 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.sql
@@ -1,5 +1,5 @@
 -- Role: "Role1_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
   LOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_role.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_role.sql
index 7b922588..fd191d4c 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_role.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_role.sql
@@ -1,5 +1,5 @@
 -- Role: "Role1_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_description.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_description.sql
index 6098d25c..9adaa120 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_description.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_description.sql
@@ -1,5 +1,5 @@
 -- Role: "Role1_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
   LOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_name.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_name.sql
index 7e4c5e33..5fa66475 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_name.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_name.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   LOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_options.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_options.sql
index 65008dee..4b91d548 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_options.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_options.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   LOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_description.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_description.sql
index ff2e6620..c3998071 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_description.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_description.sql
@@ -1,5 +1,5 @@
 -- Role: "Role1_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_name.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_name.sql
index 5c757fc9..16fb4471 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_name.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_name.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options1.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options1.sql
index 4c82ac17..f24d8d73 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options1.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options1.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options2.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options2.sql
index bcd7e779..34be0176 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options2.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options2.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options3.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options3.sql
index 17493540..b099718a 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options3.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options3.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options4.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options4.sql
index 89a9da4f..454721fe 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options4.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options4.sql
@@ -1,5 +1,5 @@
 -- Role: "Role2_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_login_role.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_login_role.sql
index 027c9d89..5f1cadca 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_login_role.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_login_role.sql
@@ -1,5 +1,5 @@
 -- Role: "Role1_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
   LOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_role.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_role.sql
index 7b922588..fd191d4c 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_role.sql
+++ b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_role.sql
@@ -1,5 +1,5 @@
 -- Role: "Role1_$%{}[]()&*^!@""'`\/#"
--- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
+-- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#";
 
 CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
   NOLOGIN
diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
index deaf72d2..d1217776 100644
--- a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
@@ -588,7 +588,7 @@ class TablespaceView(PGChildNodeView):
         sql_header = """
 -- Tablespace: {0}
 
--- DROP TABLESPACE {0};
+-- DROP TABLESPACE IF EXISTS {0};
 
 """.format(old_data['name'])
 
