Easiest way to migrate a PostgreSQL database into an SQL Server one -
i have postgresql database want move sql server -- both schema , data. poor don't want pay money. lazy, don't want work. i'm doing table table, , there 100 tables do. extremely tedious.
is there sort of trick want?
i believe may have gotten down-votes due amazing ease of generating simple sql script postgresql can (theoretically) run again dbms. if 1 regular postgresql user, sounds dumb question.
that's not fair since turns out moderately hard problem (although more due sql server's odd syntax , interface failing of postgresql).
you should able find useful information in accepted answer in serverfault page: https://serverfault.com/questions/65407/best-tool-to-migrate-a-postgresql-database-to-ms-sql-2005.
if can schema converted without data, may able shorten steps data using command:
pg_dump --data-only --column-inserts your_db_name > data_load_script.sql this load quite slow, --column-inserts option generates generic insert statements possible each row of data , should compatible.
edit: suggestions on converting schema follows:
i start dumping schema, removing has ownership or permissions. should enough:
pg_dump --schema-only --no-owner --no-privileges your_db_name > schema_create_script.sql edit file add line begin transaction; beginning , rollback transaction; end. can load , run in query window in sql server. if errors, make sure go bottom of file, highlight rollback statement , run (by hitting f5 while statement highlighted).
basically, have resolve each error until script runs through cleanly. can change rollback transaction commit transaction , run 1 final time.
unfortunately, cannot errors may see have never gone postgresql sql server, other way around. things expect issue, (obviously, not exhaustive list):
- postgresql auto-increment fields linking
not null integerfieldsequenceusingdefault. in sql server,identitycolumn, they're not same thing. i'm not sure if equivalent, if original schema full of "id" fields, may in trouble. don't know if sql server hascreate sequence, may have remove those. - database functions / stored procedures not translate between rdbms platforms. you'll need remove
create functionstatements , translate algorithms manually. - be careful encoding of data file. i'm linux person, have no idea how verify encoding in windows, need make sure sql server expects same file importing postgresql.
pg_dumphas option--encoding=let set specific encoding. seem recall windows tends use two-byte, utf-16 encoding unicode postgresql uses utf-8. had issue going sql server postgresql due utf-16 output worth researching. - the postgresql datatype
textvarcharwithout max length. in sql server,textis... complicated (and deprecated). each field in original schema declaredtextneed reviewed appropriate sql server data type. - sql server has data types
unicodedata. i'm not familiar enough make suggestions. i'm pointing out may issue.
Comments
Post a Comment