diff --git a/pgadmin/dlg/dlgSequence.cpp b/pgadmin/dlg/dlgSequence.cpp
index 39319ca..d5ae231 100644
--- a/pgadmin/dlg/dlgSequence.cpp
+++ b/pgadmin/dlg/dlgSequence.cpp
@@ -248,13 +248,37 @@ wxString dlgSequence::GetSql()
 
 		if (GetName() != sequence->GetName())
 		{
-			sql += wxT("ALTER TABLE ") + sequence->GetQuotedFullIdentifier()
-			       +  wxT("\n  RENAME TO ") + qtIdent(name) + wxT(";\n");
+			if (connection->BackendMinimumVersion(8, 3))
+			{
+				sql += wxT("ALTER SEQUENCE ") + sequence->GetQuotedFullIdentifier()
+				       +  wxT("\n  RENAME TO ") + qtIdent(name) + wxT(";\n");
+			}
+			else
+			{
+				sql += wxT("ALTER TABLE ") + sequence->GetQuotedFullIdentifier()
+				       +  wxT("\n  RENAME TO ") + qtIdent(name) + wxT(";\n");
+			}
 		}
 		if (sequence->GetOwner() != cbOwner->GetValue())
 		{
-			sql += wxT("ALTER TABLE ") + schema->GetQuotedPrefix() + qtIdent(name)
-			       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+			if (connection->BackendMinimumVersion(8, 2))
+			{
+				sql += wxT("ALTER SEQUENCE ") + schema->GetQuotedPrefix() + qtIdent(name);
+
+				if (connection->BackendMinimumVersion(8, 4))
+				{
+					sql += wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+				}
+				else
+				{
+					sql += wxT("\n  OWNED BY ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+				}
+			}
+			else
+			{
+				sql += wxT("ALTER TABLE ") + schema->GetQuotedPrefix() + qtIdent(name)
+				       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+			}
 		}
 
 		// This is where things get hairy. Per some thought by Horvath Gabor,
@@ -341,8 +365,24 @@ wxString dlgSequence::GetSql()
 		sql += wxT(";\n");
 		if (cbOwner->GetGuessedSelection() > 0)
 		{
-			sql += wxT("ALTER TABLE ")  + schema->GetQuotedPrefix() + qtIdent(name)
-			       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+			if (connection->BackendMinimumVersion(8, 2))
+			{
+				sql += wxT("ALTER SEQUENCE ") + schema->GetQuotedPrefix() + qtIdent(name);
+
+				if (connection->BackendMinimumVersion(8, 4))
+				{
+					sql += wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+				}
+				else
+				{
+					sql += wxT("\n  OWNED BY ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+				}
+			}
+			else
+			{
+				sql += wxT("ALTER TABLE ") + schema->GetQuotedPrefix() + qtIdent(name)
+				       +  wxT("\n  OWNER TO ") + qtIdent(cbOwner->GetValue()) + wxT(";\n");
+			}
 		}
 	}
 