diff --git a/pgadmin/dlg/dlgCheck.cpp b/pgadmin/dlg/dlgCheck.cpp
index 268b571..c388ef9 100644
--- a/pgadmin/dlg/dlgCheck.cpp
+++ b/pgadmin/dlg/dlgCheck.cpp
@@ -109,9 +109,9 @@ wxString dlgCheck::GetSql()
 	if (!check)
 	{
 		sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-		      + wxT(" ADD");
+		      + wxT("\n  ADD");
 		AppendIfFilled(sql, wxT(" CONSTRAINT "), qtIdent(name));
-		sql += wxT(" CHECK ") + GetDefinition()
+		sql += wxT("\n  CHECK ") + GetDefinition()
 		       + wxT(";\n");
 	}
 	if (!name.IsEmpty())
diff --git a/pgadmin/dlg/dlgDatabase.cpp b/pgadmin/dlg/dlgDatabase.cpp
index 54db208..195ea55 100644
--- a/pgadmin/dlg/dlgDatabase.cpp
+++ b/pgadmin/dlg/dlgDatabase.cpp
@@ -673,7 +673,7 @@ wxString dlgDatabase::GetSql()
 			if (cbTablespace->GetCurrentSelection() > 0 && cbTablespace->GetOIDKey() > 0
 			        && cbTablespace->GetOIDKey() != database->GetTablespaceOid())
 				sql += wxT("ALTER DATABASE ") + qtIdent(name)
-				       +  wxT(" SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
+				       +  wxT("\n  SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
 				       +  wxT(";\n");
 		}
 		if (connection->BackendMinimumVersion(8, 1))
@@ -690,7 +690,7 @@ wxString dlgDatabase::GetSql()
 				wxString strConnLimit;
 				strConnLimit << connLimit;
 				sql += wxT("ALTER DATABASE ") + qtIdent(name)
-				       +  wxT(" WITH CONNECTION LIMIT = ")
+				       +  wxT("\n  WITH CONNECTION LIMIT = ")
 				       +  strConnLimit
 				       +  wxT(";\n");
 			}
@@ -749,9 +749,9 @@ wxString dlgDatabase::GetSql()
 					sql += wxT("ALTER ROLE ") + newUsr + wxT(" IN DATABASE ") + qtIdent(name);
 
 				if (newVar != wxT("search_path") && newVar != wxT("temp_tablespaces"))
-					sql += wxT(" SET ") + newVar + wxT("='") + newVal + wxT("';\n");
+					sql += wxT("\n  SET ") + newVar + wxT("='") + newVal + wxT("';\n");
 				else
-					sql += wxT(" SET ") + newVar + wxT("=") + newVal + wxT(";\n");
+					sql += wxT("\n  SET ") + newVar + wxT("=") + newVal + wxT(";\n");
 			}
 		}
 
@@ -769,13 +769,13 @@ wxString dlgDatabase::GetSql()
 			if (username.Length() == 0)
 			{
 				sql += wxT("ALTER DATABASE ") + qtIdent(name)
-				       +  wxT(" RESET ") + varname
+				       +  wxT("\n  RESET ") + varname
 				       + wxT(";\n");
 			}
 			else
 			{
 				sql += wxT("ALTER ROLE ") + username + wxT(" IN DATABASE ") + qtIdent(name)
-				       +  wxT(" RESET ") + varname + wxT(";\n");
+				       +  wxT("\n  RESET ") + varname + wxT(";\n");
 			}
 		}
 
@@ -845,9 +845,9 @@ wxString dlgDatabase::GetSql2()
 				sql += wxT("ALTER ROLE ") + newUsr + wxT(" IN DATABASE ") + qtIdent(name);
 
 			if (newVar != wxT("search_path") && newVar != wxT("temp_tablespaces"))
-				sql += wxT(" SET ") + newVar + wxT("='") + newVal + wxT("';\n");
+				sql += wxT("\n  SET ") + newVar + wxT("='") + newVal + wxT("';\n");
 			else
-				sql += wxT(" SET ") + newVar + wxT("=") + newVal + wxT(";\n");
+				sql += wxT("\n  SET ") + newVar + wxT("=") + newVal + wxT(";\n");
 		}
 	}
 
diff --git a/pgadmin/dlg/dlgDomain.cpp b/pgadmin/dlg/dlgDomain.cpp
index 1538018..94150a1 100644
--- a/pgadmin/dlg/dlgDomain.cpp
+++ b/pgadmin/dlg/dlgDomain.cpp
@@ -199,17 +199,17 @@ wxString dlgDomain::GetSql()
 		{
 			sql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier();
 			if (chkNotNull->GetValue())
-				sql += wxT(" SET NOT NULL;\n");
+				sql += wxT("\n  SET NOT NULL;\n");
 			else
-				sql += wxT(" DROP NOT NULL;\n");
+				sql += wxT("\n  DROP NOT NULL;\n");
 		}
 		if (txtDefault->GetValue() != domain->GetDefault())
 		{
 			sql += wxT("ALTER DOMAIN ") + domain->GetQuotedFullIdentifier();
 			if (txtDefault->GetValue().IsEmpty())
-				sql += wxT(" DROP DEFAULT;\n");
+				sql += wxT("\n  DROP DEFAULT;\n");
 			else
-				sql += wxT(" SET DEFAULT ") + txtDefault->GetValue() + wxT(";\n");
+				sql += wxT("\n  SET DEFAULT ") + txtDefault->GetValue() + wxT(";\n");
 		}
 		AppendOwnerChange(sql, wxT("DOMAIN ") + domain->GetQuotedFullIdentifier());
 	}
diff --git a/pgadmin/dlg/dlgExtension.cpp b/pgadmin/dlg/dlgExtension.cpp
index 2dc5191..3beeb0f 100644
--- a/pgadmin/dlg/dlgExtension.cpp
+++ b/pgadmin/dlg/dlgExtension.cpp
@@ -182,10 +182,10 @@ wxString dlgExtension::GetSql()
 		// edit mode
 		if (cbSchema->GetValue() != extension->GetSchemaStr())
 			sql += wxT("ALTER EXTENSION ") + qtIdent(extension->GetName())
-			       +  wxT(" SET SCHEMA ") + qtIdent(cbSchema->GetValue()) + wxT(";\n");
+			       +  wxT("\n  SET SCHEMA ") + qtIdent(cbSchema->GetValue()) + wxT(";\n");
 		if (cbVersion->GetValue() != extension->GetVersion())
 			sql += wxT("ALTER EXTENSION ") + qtIdent(extension->GetName())
-			       +  wxT(" UPDATE TO ") + qtIdent(cbVersion->GetValue()) + wxT(";\n");
+			       +  wxT("\n  UPDATE TO ") + qtIdent(cbVersion->GetValue()) + wxT(";\n");
 	}
 	else
 	{
diff --git a/pgadmin/dlg/dlgForeignKey.cpp b/pgadmin/dlg/dlgForeignKey.cpp
index 4cad066..c028740 100644
--- a/pgadmin/dlg/dlgForeignKey.cpp
+++ b/pgadmin/dlg/dlgForeignKey.cpp
@@ -466,7 +466,7 @@ wxString dlgForeignKey::GetSql()
 	if (!foreignKey)
 	{
 		sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-		      + wxT(" ADD");
+		      + wxT("\n  ADD");
 		AppendIfFilled(sql, wxT(" CONSTRAINT "), qtIdent(name));
 		sql += wxT(" FOREIGN KEY ") + GetDefinition()
 		       + wxT(";\n");
@@ -474,7 +474,7 @@ wxString dlgForeignKey::GetSql()
 	else if (!chkDontValidate->GetValue())
 	{
 		sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-		      + wxT(" VALIDATE CONSTRAINT ") + qtIdent(name) + wxT(";\n");
+		      + wxT("\n  VALIDATE CONSTRAINT ") + qtIdent(name) + wxT(";\n");
 	}
 
 	if (!name.IsEmpty())
@@ -484,7 +484,7 @@ wxString dlgForeignKey::GetSql()
 	if (chkAutoIndex->GetValue())
 	{
 		sql += wxT("CREATE INDEX ") + qtIdent(txtIndexName->GetValue())
-		       +  wxT(" ON ") + table->GetQuotedFullIdentifier()
+		       +  wxT("\n  ON ") + table->GetQuotedFullIdentifier()
 		       +  wxT("(");
 
 		int pos;
diff --git a/pgadmin/dlg/dlgForeignServer.cpp b/pgadmin/dlg/dlgForeignServer.cpp
index 6450513..5e18281 100644
--- a/pgadmin/dlg/dlgForeignServer.cpp
+++ b/pgadmin/dlg/dlgForeignServer.cpp
@@ -282,14 +282,14 @@ wxString dlgForeignServer::GetSql()
 		if (txtVersion->GetValue() != foreignserver->GetVersion())
 		{
 			sql = wxT("ALTER SERVER ") + qtIdent(name)
-			      + wxT(" VERSION ") + qtDbString(txtVersion->GetValue()) + wxT(";\n");
+			      + wxT("\n  VERSION ") + qtDbString(txtVersion->GetValue()) + wxT(";\n");
 		}
 
 		wxString sqloptions = GetOptionsSql();
 		if (sqloptions.Length() > 0)
 		{
 			sql += wxT("ALTER SERVER ") + name
-			       + wxT(" OPTIONS (") + sqloptions + wxT(");\n");
+			       + wxT("\n  OPTIONS (") + sqloptions + wxT(");\n");
 		}
 
 		AppendOwnerChange(sql, wxT("SERVER ") + qtIdent(name));
diff --git a/pgadmin/dlg/dlgForeignTable.cpp b/pgadmin/dlg/dlgForeignTable.cpp
index e60c717..a7f96e2 100644
--- a/pgadmin/dlg/dlgForeignTable.cpp
+++ b/pgadmin/dlg/dlgForeignTable.cpp
@@ -511,7 +511,7 @@ wxString dlgForeignTable::GetSql()
 		if (sqloptions.Length() > 0)
 		{
 			sql += wxT("ALTER FOREIGN TABLE ") + foreigntable->GetQuotedFullIdentifier()
-			       + wxT(" OPTIONS (") + sqloptions + wxT(");\n");
+			       + wxT("\n  OPTIONS (") + sqloptions + wxT(");\n");
 		}
 	}
 	else
@@ -595,7 +595,7 @@ wxString dlgForeignTable::GetSqlForTypes()
 		{
 			old_name = elements.Item(i);
 			sql += wxT("ALTER FOREIGN TABLE ") + foreigntable->GetQuotedFullIdentifier()
-			       + wxT(" DROP COLUMN ") + old_name + wxT(";\n");
+			       + wxT("\n  DROP COLUMN ") + old_name + wxT(";\n");
 		}
 
 		// Add all new attributes
@@ -604,7 +604,7 @@ wxString dlgForeignTable::GetSqlForTypes()
 			new_name = lstMembers->GetItemText(i);
 			new_type = GetFullTypeName(i);
 			sql += wxT("ALTER FOREIGN TABLE ") + foreigntable->GetQuotedFullIdentifier()
-			       + wxT(" ADD COLUMN ") + new_name + wxT(" ") + new_type + wxT(";\n");
+			       + wxT("\n  ADD COLUMN ") + new_name + wxT(" ") + new_type + wxT(";\n");
 		}
 	}
 
diff --git a/pgadmin/dlg/dlgFunction.cpp b/pgadmin/dlg/dlgFunction.cpp
index 78d12af..274d7cd 100644
--- a/pgadmin/dlg/dlgFunction.cpp
+++ b/pgadmin/dlg/dlgFunction.cpp
@@ -866,10 +866,10 @@ wxString dlgFunction::GetSql()
 			if (!isProcedure)
 				sql = wxT("ALTER FUNCTION ") + function->GetQuotedFullIdentifier()
 				      + wxT("(") + function->GetArgSigList() + wxT(")")
-				      + wxT(" RENAME TO ") + qtIdent(name) + wxT(";\n");
+				      + wxT("\n  RENAME TO ") + qtIdent(name) + wxT(";\n");
 			else
 				sql = wxT("ALTER PROCEDURE ") + function->GetQuotedFullIdentifier()
-				      + wxT(" RENAME TO ") + qtIdent(name) + wxT(";\n");
+				      + wxT("\n  RENAME TO ") + qtIdent(name) + wxT(";\n");
 		}
 
 		if (didChange)
@@ -961,7 +961,7 @@ wxString dlgFunction::GetSql()
 	{
 		if (cbOwner->GetValue() != function->GetOwner())
 			sql += wxT("ALTER FUNCTION ") + name
-			       +  wxT(" OWNER TO ") + qtIdent(cbOwner->GetValue())
+			       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue())
 			       + wxT(";\n");
 	}
 	else
@@ -1011,12 +1011,12 @@ wxString dlgFunction::GetSql()
 			{
 				if (newVar != wxT("search_path") && newVar != wxT("temp_tablespaces"))
 					sql += wxT("ALTER FUNCTION ") + name
-					       +  wxT(" SET ") + newVar
+					       +  wxT("\n  SET ") + newVar
 					       +  wxT("='") + newVal
 					       +  wxT("';\n");
 				else
 					sql += wxT("ALTER FUNCTION ") + name
-					       +  wxT(" SET ") + newVar
+					       +  wxT("\n  SET ") + newVar
 					       +  wxT("=") + newVal
 					       +  wxT(";\n");
 			}
@@ -1026,7 +1026,7 @@ wxString dlgFunction::GetSql()
 		for (pos = 0 ; pos < (int)vars.GetCount() ; pos++)
 		{
 			sql += wxT("ALTER FUNCTION ") + name
-			       +  wxT(" RESET ") + vars.Item(pos).BeforeFirst('=')
+			       +  wxT("\n  RESET ") + vars.Item(pos).BeforeFirst('=')
 			       + wxT(";\n");
 		}
 
diff --git a/pgadmin/dlg/dlgGroup.cpp b/pgadmin/dlg/dlgGroup.cpp
index 05bd206..2f10ba2 100644
--- a/pgadmin/dlg/dlgGroup.cpp
+++ b/pgadmin/dlg/dlgGroup.cpp
@@ -183,14 +183,14 @@ wxString dlgGroup::GetSql()
 				tmpUsers.RemoveAt(index);
 			else
 				sql += wxT("ALTER GROUP ") + qtIdent(name)
-				       +  wxT(" ADD USER ") + qtIdent(userName) + wxT(";\n");
+				       +  wxT("\n  ADD USER ") + qtIdent(userName) + wxT(";\n");
 		}
 
 		// check for removed users
 		for (pos = 0 ; pos < (int)tmpUsers.GetCount() ; pos++)
 		{
 			sql += wxT("ALTER GROUP ") + qtIdent(name)
-			       +  wxT(" DROP USER ") + qtIdent(tmpUsers.Item(pos)) + wxT(";\n");
+			       +  wxT("\n  DROP USER ") + qtIdent(tmpUsers.Item(pos)) + wxT(";\n");
 		}
 	}
 	else
diff --git a/pgadmin/dlg/dlgIndex.cpp b/pgadmin/dlg/dlgIndex.cpp
index e86cc62..072be77 100644
--- a/pgadmin/dlg/dlgIndex.cpp
+++ b/pgadmin/dlg/dlgIndex.cpp
@@ -624,7 +624,7 @@ wxString dlgIndex::GetSql()
 		{
 			if (connection->BackendMinimumVersion(8, 2) && txtFillFactor->GetValue().Length() > 0)
 				sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetName()) + wxT(".")
-				       + qtIdent(index->GetName()) +  wxT(" SET (FILLFACTOR=")
+				       + qtIdent(index->GetName()) +  wxT("\n  SET (FILLFACTOR=")
 				       + txtFillFactor->GetValue() + wxT(");\n");
 
 			if(connection->BackendMinimumVersion(8, 0))
@@ -632,12 +632,12 @@ wxString dlgIndex::GetSql()
 				if (index->GetName() != txtName->GetValue() &&
 				        !txtName->GetValue().IsEmpty())
 					sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetName()) + wxT(".")
-					       + qtIdent(index->GetName()) +  wxT(" RENAME TO ")
+					       + qtIdent(index->GetName()) +  wxT("\n  RENAME TO ")
 					       + qtIdent(txtName->GetValue()) + wxT(";\n");
 
 				if (cbTablespace->GetOIDKey() != index->GetTablespaceOid())
 					sql += wxT("ALTER INDEX ") + qtIdent(index->GetSchema()->GetName()) + wxT(".") + qtIdent(name)
-					       +  wxT(" SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
+					       +  wxT("\n  SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
 					       +  wxT(";\n");
 			}
 		}
@@ -645,10 +645,10 @@ wxString dlgIndex::GetSql()
 		{
 			if (index && index->GetIsClustered() && !chkClustered->GetValue())
 				sql += wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-				       +  wxT(" SET WITHOUT CLUSTER;\n");
+				       +  wxT("\n  SET WITHOUT CLUSTER;\n");
 			else if (chkClustered->GetValue() && (!index || !index->GetIsClustered()))
 				sql += wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-				       +  wxT(" CLUSTER ON ") + qtIdent(name) + wxT(";\n");
+				       +  wxT("\n  CLUSTER ON ") + qtIdent(name) + wxT(";\n");
 		}
 
 		AppendComment(sql, wxT("INDEX"), table->GetSchema(), index);
diff --git a/pgadmin/dlg/dlgIndexConstraint.cpp b/pgadmin/dlg/dlgIndexConstraint.cpp
index 1ae8dcc..ef296c6 100644
--- a/pgadmin/dlg/dlgIndexConstraint.cpp
+++ b/pgadmin/dlg/dlgIndexConstraint.cpp
@@ -554,7 +554,7 @@ wxString dlgIndexConstraint::GetSql()
 	if (!index)
 	{
 		sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-		      + wxT(" ADD");
+		      + wxT("\n  ADD");
 		AppendIfFilled(sql, wxT(" CONSTRAINT "), qtIdent(name));
 
 		sql += wxT(" ") + wxString(factory->GetTypeName()).Upper() + wxT(" ") + GetDefinition()
@@ -565,7 +565,7 @@ wxString dlgIndexConstraint::GetSql()
 		if (connection->BackendMinimumVersion(8, 0) && cbTablespace->GetOIDKey() != index->GetTablespaceOid())
 		{
 			sql += wxT("ALTER INDEX ") + index->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
-			       +  wxT(" SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
+			       +  wxT("\n  SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
 			       + wxT(";\n");
 		}
 
diff --git a/pgadmin/dlg/dlgLanguage.cpp b/pgadmin/dlg/dlgLanguage.cpp
index 07237ef..36beb72 100644
--- a/pgadmin/dlg/dlgLanguage.cpp
+++ b/pgadmin/dlg/dlgLanguage.cpp
@@ -192,7 +192,7 @@ wxString dlgLanguage::GetSql()
 		// edit mode
 		if (name != language->GetName())
 			sql += wxT("ALTER LANGUAGE ") + qtIdent(language->GetName())
-			       +  wxT(" RENAME TO ") + qtIdent(name) + wxT(";\n");
+			       +  wxT("\n  RENAME TO ") + qtIdent(name) + wxT(";\n");
 		if (connection->BackendMinimumVersion(8, 3))
 			AppendOwnerChange(sql, wxT("LANGUAGE ") + qtIdent(name));
 	}
diff --git a/pgadmin/dlg/dlgOperator.cpp b/pgadmin/dlg/dlgOperator.cpp
index 8cd9f45..b3a9eeb 100644
--- a/pgadmin/dlg/dlgOperator.cpp
+++ b/pgadmin/dlg/dlgOperator.cpp
@@ -401,7 +401,7 @@ wxString dlgOperator::GetSql()
 
 		if (cbOwner->GetValue() != oper->GetOwner())
 			sql += wxT("ALTER OPERATOR ") + name
-			       +  wxT(" OWNER TO ") + qtIdent(cbOwner->GetValue())
+			       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue())
 			       +  wxT(";\n");
 	}
 	else
diff --git a/pgadmin/dlg/dlgProperty.cpp b/pgadmin/dlg/dlgProperty.cpp
index 8cc812a..aa76a54 100644
--- a/pgadmin/dlg/dlgProperty.cpp
+++ b/pgadmin/dlg/dlgProperty.cpp
@@ -423,14 +423,14 @@ void dlgProperty::AppendNameChange(wxString &sql, const wxString &objName)
 		if (objName.Length() > 0)
 		{
 			sql += wxT("ALTER ") + objName
-			       +  wxT(" RENAME TO ") + qtIdent(GetName())
+			       +  wxT("\n  RENAME TO ") + qtIdent(GetName())
 			       +  wxT(";\n");
 		}
 		else
 		{
 			sql += wxT("ALTER ") + GetObject()->GetTypeName().MakeUpper()
 			       +  wxT(" ") + GetObject()->GetQuotedFullIdentifier()
-			       +  wxT(" RENAME TO ") + qtIdent(GetName())
+			       +  wxT("\n  RENAME TO ") + qtIdent(GetName())
 			       +  wxT(";\n");
 		}
 	}
@@ -442,7 +442,7 @@ void dlgProperty::AppendOwnerChange(wxString &sql, const wxString &objName)
 	if (GetObject()->GetOwner() != cbOwner->GetValue())
 	{
 		sql += wxT("ALTER ") + objName
-		       +  wxT(" OWNER TO ") + qtIdent(cbOwner->GetValue())
+		       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue())
 		       +  wxT(";\n");
 	}
 }
@@ -452,7 +452,7 @@ void dlgProperty::AppendOwnerNew(wxString &sql, const wxString &objName)
 {
 	if (cbOwner->GetGuessedSelection() > 0)
 		sql += wxT("ALTER ") + objName
-		       +  wxT(" OWNER TO ") + qtIdent(cbOwner->GetValue())
+		       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue())
 		       +  wxT(";\n");
 }
 
diff --git a/pgadmin/dlg/dlgRole.cpp b/pgadmin/dlg/dlgRole.cpp
index d7da7fb..4dc80ff 100644
--- a/pgadmin/dlg/dlgRole.cpp
+++ b/pgadmin/dlg/dlgRole.cpp
@@ -779,12 +779,12 @@ wxString dlgRole::GetSql()
 		{
 			if (newVar != wxT("search_path") && newVar != wxT("temp_tablespaces"))
 				sql += wxT("ALTER ROLE ") + qtIdent(name)
-				       +  wxT(" SET ") + newVar
+				       +  wxT("\n  SET ") + newVar
 				       +  wxT("='") + newVal
 				       +  wxT("';\n");
 			else
 				sql += wxT("ALTER ROLE ") + qtIdent(name)
-				       +  wxT(" SET ") + newVar
+				       +  wxT("\n  SET ") + newVar
 				       +  wxT("=") + newVal
 				       +  wxT(";\n");
 		}
@@ -794,7 +794,7 @@ wxString dlgRole::GetSql()
 	for (pos = 0 ; pos < (int)vars.GetCount() ; pos++)
 	{
 		sql += wxT("ALTER ROLE ") + qtIdent(name)
-		       +  wxT(" RESET ") + vars.Item(pos).BeforeFirst('=')
+		       +  wxT("\n  RESET ") + vars.Item(pos).BeforeFirst('=')
 		       + wxT(";\n");
 	}
 
diff --git a/pgadmin/dlg/dlgSequence.cpp b/pgadmin/dlg/dlgSequence.cpp
index 39319ca..415c795 100644
--- a/pgadmin/dlg/dlgSequence.cpp
+++ b/pgadmin/dlg/dlgSequence.cpp
@@ -249,12 +249,12 @@ wxString dlgSequence::GetSql()
 		if (GetName() != sequence->GetName())
 		{
 			sql += wxT("ALTER TABLE ") + sequence->GetQuotedFullIdentifier()
-			       +  wxT(" RENAME TO ") + qtIdent(name) + wxT(";\n");
+			       +  wxT("\n  RENAME TO ") + qtIdent(name) + wxT(";\n");
 		}
 		if (sequence->GetOwner() != cbOwner->GetValue())
 		{
 			sql += wxT("ALTER TABLE ") + schema->GetQuotedPrefix() + qtIdent(name)
-			       +  wxT(" OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+			       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
 		}
 
 		// This is where things get hairy. Per some thought by Horvath Gabor,
@@ -342,7 +342,7 @@ wxString dlgSequence::GetSql()
 		if (cbOwner->GetGuessedSelection() > 0)
 		{
 			sql += wxT("ALTER TABLE ")  + schema->GetQuotedPrefix() + qtIdent(name)
-			       +  wxT(" OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+			       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
 		}
 	}
 
diff --git a/pgadmin/dlg/dlgTable.cpp b/pgadmin/dlg/dlgTable.cpp
index 6aa86b1..8022119 100644
--- a/pgadmin/dlg/dlgTable.cpp
+++ b/pgadmin/dlg/dlgTable.cpp
@@ -814,7 +814,7 @@ wxString dlgTable::GetSql()
 					if (index < 0)
 					{
 						tmpsql += wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-						          +  wxT(" ADD COLUMN ") + definition + wxT(";\n");
+						          +  wxT("\n  ADD COLUMN ") + definition + wxT(";\n");
 						//addcomment
 					}
 				}
@@ -851,7 +851,7 @@ wxString dlgTable::GetSql()
 			else
 				definition = definition.BeforeFirst(' ');
 			sql += wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-			       +  wxT(" DROP COLUMN ") + qtIdent(definition) + wxT(";\n");
+			       +  wxT("\n  DROP COLUMN ") + qtIdent(definition) + wxT(";\n");
 		}
 		// Add the ADD COLUMNs...
 		sql += tmpsql;
@@ -869,7 +869,7 @@ wxString dlgTable::GetSql()
 			index = tmpDef.Index(definition);
 			if (index < 0)
 				tmpsql += wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-				          +  wxT(" INHERIT ") + definition + wxT(";\n");
+				          +  wxT("\n  INHERIT ") + definition + wxT(";\n");
 			else
 				tmpDef.RemoveAt(index);
 		}
@@ -878,7 +878,7 @@ wxString dlgTable::GetSql()
 		{
 			definition = tmpDef.Item(index);
 			sql += wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
-			       +  wxT(" NO INHERIT ") + qtIdent(definition) + wxT(";\n");
+			       +  wxT("\n  NO INHERIT ") + qtIdent(definition) + wxT(";\n");
 		}
 		// Add the INHERIT COLUMNs...
 		sql += tmpsql;
@@ -899,7 +899,7 @@ wxString dlgTable::GetSql()
 			else
 			{
 				tmpsql += wxT("ALTER TABLE ") + tabname
-				          +  wxT(" ADD");
+				          +  wxT("\n  ADD");
 				if (!conname.IsEmpty())
 					tmpsql += wxT(" CONSTRAINT ");
 
@@ -915,7 +915,7 @@ wxString dlgTable::GetSql()
 			else
 				definition = definition.BeforeFirst(' ');
 			sql = wxT("ALTER TABLE ") + tabname
-			      + wxT(" DROP CONSTRAINT ") + qtIdent(definition) + wxT(";\n")
+			      + wxT("\n  DROP CONSTRAINT ") + qtIdent(definition) + wxT(";\n")
 			      + sql;
 
 		}
@@ -925,16 +925,16 @@ wxString dlgTable::GetSql()
 		if (!chkHasOids->GetValue() && table->GetHasOids())
 		{
 			sql += wxT("ALTER TABLE ") + tabname
-			       +  wxT(" SET WITHOUT OIDS;\n");
+			       +  wxT("\n  SET WITHOUT OIDS;\n");
 		}
 		if (chkHasOids->GetValue() && !table->GetHasOids())
 		{
 			sql += wxT("ALTER TABLE ") + tabname
-			       +  wxT(" SET WITH OIDS;\n");
+			       +  wxT("\n  SET WITH OIDS;\n");
 		}
 		if (connection->BackendMinimumVersion(8, 0) && cbTablespace->GetOIDKey() != table->GetTablespaceOid())
 			sql += wxT("ALTER TABLE ") + tabname
-			       +  wxT(" SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
+			       +  wxT("\n  SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
 			       + wxT(";\n");
 
 		if (txtFillFactor->GetValue().Trim().Length() > 0 && txtFillFactor->GetValue() != table->GetFillFactor())
@@ -1474,8 +1474,8 @@ wxString dlgTable::GetSql()
 		{
 			if (!lstColumns->GetText(pos, 4).IsEmpty())
 				sql += wxT("ALTER TABLE ") + tabname
-				       + wxT(" ALTER COLUMN ") + qtIdent(lstColumns->GetText(pos, 0))
-				       + wxT(" SET STATISTICS ") + lstColumns->GetText(pos, 4)
+				       + wxT("\n  ALTER COLUMN ") + qtIdent(lstColumns->GetText(pos, 0))
+				       + wxT("\n  SET STATISTICS ") + lstColumns->GetText(pos, 4)
 				       + wxT(";\n");
 		}
 	}
diff --git a/pgadmin/dlg/dlgTablespace.cpp b/pgadmin/dlg/dlgTablespace.cpp
index f136a36..20f9368 100644
--- a/pgadmin/dlg/dlgTablespace.cpp
+++ b/pgadmin/dlg/dlgTablespace.cpp
@@ -227,7 +227,7 @@ wxString dlgTablespace::GetSql()
 			if (oldVal != newVal)
 			{
 				sql += wxT("ALTER TABLESPACE ") + qtIdent(name)
-				       +  wxT(" SET (") + newVar
+				       +  wxT("\n  SET (") + newVar
 				       +  wxT("=") + newVal
 				       +  wxT(");\n");
 			}
@@ -237,7 +237,7 @@ wxString dlgTablespace::GetSql()
 		for (pos = 0 ; pos < (int)vars.GetCount() ; pos++)
 		{
 			sql += wxT("ALTER TABLESPACE ") + qtIdent(name)
-			       +  wxT(" RESET (") + vars.Item(pos).BeforeFirst('=')
+			       +  wxT("\n  RESET (") + vars.Item(pos).BeforeFirst('=')
 			       + wxT(");\n");
 		}
 	}
@@ -245,8 +245,8 @@ wxString dlgTablespace::GetSql()
 	{
 		// Create Mode
 		sql = wxT("CREATE TABLESPACE ") + qtIdent(name);
-		AppendIfFilled(sql, wxT(" OWNER "), qtIdent(cbOwner->GetValue()));
-		sql += wxT(" LOCATION ") + qtDbString(txtLocation->GetValue())
+		AppendIfFilled(sql, wxT("\n  OWNER "), qtIdent(cbOwner->GetValue()));
+		sql += wxT("\n  LOCATION ") + qtDbString(txtLocation->GetValue())
 		       +  wxT(";\n");
 	}
 
@@ -268,7 +268,7 @@ wxString dlgTablespace::GetSql2()
 		for (int pos = 0 ; pos < lstVariables->GetItemCount() ; pos++)
 		{
 			sql += wxT("ALTER TABLESPACE ") + qtIdent(name)
-			       +  wxT(" SET (") + lstVariables->GetText(pos)
+			       +  wxT("\n  SET (") + lstVariables->GetText(pos)
 			       +  wxT("=") + lstVariables->GetText(pos, 1)
 			       +  wxT(");\n");
 		}
diff --git a/pgadmin/dlg/dlgTrigger.cpp b/pgadmin/dlg/dlgTrigger.cpp
index 9eb41e7..657e0a7 100644
--- a/pgadmin/dlg/dlgTrigger.cpp
+++ b/pgadmin/dlg/dlgTrigger.cpp
@@ -274,7 +274,7 @@ wxString dlgTrigger::GetSql()
 	{
 		if (name != trigger->GetName())
 			sql = wxT("ALTER TRIGGER ") + trigger->GetQuotedIdentifier() + wxT(" ON ") + table->GetQuotedFullIdentifier()
-			      + wxT(" RENAME TO ") + qtIdent(name) + wxT(";\n\n");
+			      + wxT("\n  RENAME TO ") + qtIdent(name) + wxT(";\n\n");
 	}
 
 	if (!trigger ||
diff --git a/pgadmin/dlg/dlgType.cpp b/pgadmin/dlg/dlgType.cpp
index a869ccf..5f3a36c 100644
--- a/pgadmin/dlg/dlgType.cpp
+++ b/pgadmin/dlg/dlgType.cpp
@@ -704,7 +704,7 @@ wxString dlgType::GetSql()
 					}
 
 					sql += wxT("ALTER TYPE ") + type->GetQuotedFullIdentifier()
-					       +  wxT(" ADD VALUE ") + connection->qtDbString(lstLabels->GetItemText(listitems_index))
+					       +  wxT("\n  ADD VALUE ") + connection->qtDbString(lstLabels->GetItemText(listitems_index))
 					       +  wxT(" ") + direction + wxT(" ")
 					       + connection->qtDbString(elements.Item(existingitems_index + offset))
 					       + wxT(";\n");
@@ -867,7 +867,7 @@ wxString dlgType::GetSqlForTypes()
 		for (i = 0 ; i < elements.GetCount() ; i += 3)
 		{
 			old_name = elements.Item(i);
-			sql += wxT("ALTER TYPE ") + type->GetName() + wxT(" DROP ATTRIBUTE ") + old_name + wxT(";\n");
+			sql += wxT("ALTER TYPE ") + type->GetName() + wxT("\n  DROP ATTRIBUTE ") + old_name + wxT(";\n");
 		}
 
 		// Add all new attributes
@@ -876,7 +876,7 @@ wxString dlgType::GetSqlForTypes()
 			new_name = lstMembers->GetItemText(i);
 			new_type = GetFullTypeName(i);
 			new_collation = memberCollations.Item(i);
-			sql += wxT("ALTER TYPE ") + type->GetName() + wxT(" ADD ATTRIBUTE ")
+			sql += wxT("ALTER TYPE ") + type->GetName() + wxT("\n  ADD ATTRIBUTE ")
 			       + new_name + wxT(" ") + new_type;
 			if (!new_collation.IsEmpty() && new_collation != wxT("pg_catalog.\"default\""))
 				sql += wxT(" COLLATE ") + new_collation;
diff --git a/pgadmin/dlg/dlgUser.cpp b/pgadmin/dlg/dlgUser.cpp
index b5b69b4..8f9f0f9 100644
--- a/pgadmin/dlg/dlgUser.cpp
+++ b/pgadmin/dlg/dlgUser.cpp
@@ -469,14 +469,14 @@ wxString dlgUser::GetSql()
 				tmpGroups.RemoveAt(index);
 			else
 				sql += wxT("ALTER GROUP ") + qtIdent(groupName)
-				       +  wxT(" ADD USER ") + qtIdent(name) + wxT(";\n");
+				       +  wxT("\n  ADD USER ") + qtIdent(name) + wxT(";\n");
 		}
 
 		// check for removed groups
 		for (pos = 0 ; pos < (int)tmpGroups.GetCount() ; pos++)
 		{
 			sql += wxT("ALTER GROUP ") + qtIdent(tmpGroups.Item(pos))
-			       +  wxT(" DROP USER ") + qtIdent(name) + wxT(";\n");
+			       +  wxT("\n  DROP USER ") + qtIdent(name) + wxT(";\n");
 		}
 	}
 	else
@@ -507,7 +507,7 @@ wxString dlgUser::GetSql()
 		int cnt = lbGroupsIn->GetCount();
 		for (pos = 0 ; pos < cnt ; pos++)
 			sql += wxT("ALTER GROUP ") + qtIdent(lbGroupsIn->GetString(pos))
-			       +  wxT(" ADD USER ") + qtIdent(name) + wxT(";\n");
+			       +  wxT("\n  ADD USER ") + qtIdent(name) + wxT(";\n");
 	}
 
 	wxArrayString vars;
@@ -543,12 +543,12 @@ wxString dlgUser::GetSql()
 		{
 			if (newVar != wxT("search_path") && newVar != wxT("temp_tablespaces"))
 				sql += wxT("ALTER USER ") + qtIdent(name)
-				       +  wxT(" SET ") + newVar
+				       +  wxT("\n  SET ") + newVar
 				       +  wxT("='") + newVal
 				       +  wxT("';\n");
 			else
 				sql += wxT("ALTER USER ") + qtIdent(name)
-				       +  wxT(" SET ") + newVar
+				       +  wxT("\n  SET ") + newVar
 				       +  wxT("=") + newVal
 				       +  wxT(";\n");
 		}
@@ -558,7 +558,7 @@ wxString dlgUser::GetSql()
 	for (pos = 0 ; pos < (int)vars.GetCount() ; pos++)
 	{
 		sql += wxT("ALTER USER ") + qtIdent(name)
-		       +  wxT(" RESET ") + vars.Item(pos).BeforeFirst('=')
+		       +  wxT("\n  RESET ") + vars.Item(pos).BeforeFirst('=')
 		       + wxT(";\n");
 	}
 
diff --git a/pgadmin/dlg/dlgUserMapping.cpp b/pgadmin/dlg/dlgUserMapping.cpp
index 92d1ac4..91192f1 100644
--- a/pgadmin/dlg/dlgUserMapping.cpp
+++ b/pgadmin/dlg/dlgUserMapping.cpp
@@ -286,7 +286,7 @@ wxString dlgUserMapping::GetSql()
 		if (sqloptions.Length() > 0)
 		{
 			sql += wxT("ALTER USER MAPPING FOR ") + usermapping->GetUsr() + wxT(" SERVER ") + foreignserver->GetName()
-			       + wxT(" OPTIONS (") + sqloptions + wxT(");\n");
+			       + wxT("\n  OPTIONS (") + sqloptions + wxT(");\n");
 		}
 	}
 	else
diff --git a/pgadmin/dlg/dlgView.cpp b/pgadmin/dlg/dlgView.cpp
index 78f1f5d..77ba9ad 100644
--- a/pgadmin/dlg/dlgView.cpp
+++ b/pgadmin/dlg/dlgView.cpp
@@ -134,7 +134,7 @@ wxString dlgView::GetSql()
 		if (name != view->GetName())
 		{
 			sql += wxT("ALTER TABLE ") + view->GetQuotedFullIdentifier()
-			       +  wxT(" RENAME TO ") + qtIdent(name) + wxT(";\n");
+			       +  wxT("\n  RENAME TO ") + qtIdent(name) + wxT(";\n");
 		}
 	}
 
