SQLT-DIFF(1p)

πŸ“¦
version 1.66 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’… SQLT-DIFF β€” find the differences b/w two schemas ✨

okay bestie, welcome to sqlt-diff, a little utility living in the User Contributed Perl Documentation corner of your system. it diffs two schemas and tells you what SQL you'd need to make the first one look like the second. no cap. πŸ¦‹


🌸 SYNOPSIS 🌸

need help? say less:

sqlt-diff -h|--help

want the whole roster of valid parsers? iconic, here:

sqlt -l|--list

and to actually diff two schemas, the main character move:

sqlt-diff [options] file_name1=parser1 file_name2=parser2

πŸŽ€ Options πŸŽ€

  • -d, --debug β€” spills all the debugging info, very nosy of you, love that
  • -t, --trace β€” turns on tracing for Parse::RecDescent, if you're feeling detective-y
  • -c, --case-insensitive β€” compares tables/columns without caring about case, because we're not gatekeeping Users vs users
  • --ignore-index-names β€” pretends index name differences aren't even a thing
  • --ignore-constraint-names β€” same energy, but for constraint names
  • --mysql_parser_version=<#####> β€” tells it which target MySQL parser version to use when dealing with /*! comments
  • --output-db=<Producer> β€” use this Producer instead of the one matching parser1 when formatting output for new tables
  • --ignore-view-sql β€” view SQL differences? never heard of her
  • --ignore-proc-sql β€” procedure SQL differences? also not on our radar
  • --no-batch-alters β€” stops it from clumping multiple alters on the same table into a single ALTER TABLE statement where possible
  • --quote=<character> β€” wraps every table and field name in statements with <character>, cute and consistent πŸ’…

✨ DESCRIPTION ✨

so sqlt-diff is the utility that builds you a file of SQL commands, and those commands are the ones you need to transform the first schema into the second one. it's not yet exhaustive in its ability to mutate the entire schema (growth mindset, okay?), but it will report the following:

  • New tables

using the Producer class of the target (second) schema, any tables missing from the first schema get generated in their entirety β€” fields, constraints, indices, the whole fit. πŸ‘‘

  • Missing/altered fields

any fields missing or altered between the two schemas get reported like this:

ALTER TABLE <table_name>
  [DROP <field_name>]
  [CHANGE <field_name> <datatype> (<size>)] ;
  • Missing/altered indices

any indices that are missing, or are a different type, or sit on different fields get flagged. indices that should be dropped get reported like this:

DROP INDEX <index_name> ON <table_name> ;

and an index of a different type or on different fields gets reported as a brand new index, like this:

CREATE [<index_type>] INDEX [<index_name>] ON <table_name>
  ( <field_name>[,<field_name>] ) ;

the ALTER, CREATE and DROP statements are all created by SQL::Translator::Producer::* β€” go peek over there for support and/or problems, fr fr.

heads up: currently (v0.0900), only MySQL is supported by this code. one day the roster will expand, but today? it's MySQL's moment. πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

Ken Youens-Clark <kclark@cpan.org>. legend behavior.


🫢 SEE ALSO 🫢

SQL::Translator, <http://sqlfairy.sourceforge.net>.


and that's the whole vibe, bestie β€” brought to you by perl v5.40.0, dated 2024-11-23. go diff something iconic. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from