Skip to main content

OnlineSchemaChange is a tool for making schema changes for MySQL tables in a non-blocking way

Examples

OSC must be run on the same host as MySQL server.

copy mode

Say we have an existing table named my_table under database test:

CREATE TABLE `my_table` (
  `id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Now if we want to run ALTER TABLE ``my_table add column data varchar(10);`` against it. Instead of feed the ALTER TABLE statement to OSC, we just need to put a CREATE TABLE statement representing the desired schema into a file /tmp/foo.sql like below:

CREATE TABLE `my_table` (
  `id` int(11) NOT NULL,
  `data` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Then run the following command:

osc_cli copy --ddl-file-list=foo.sql --socket=/tmp/mysql.socket --database=test

cleanup mode

To cleanup the table left behind by last run of OSC

osc_cli cleanup --socket=/tmp/mysql.socket --database=test

To terminate a currently running OSC process on certain MySQL Instance:

osc_cli cleanup

direct mode

This mode is reserved for utilizing MySQL’s native online ddl for schema change, and help DBA manage all the schema related operation into this one tool. For now, if you plan to use OSC for all your schema management, this mode is here for you to create a empty new table. Following command will create an empty table into database test

osc_cli direct --ddl-file-list=foo.sql --socket=/tmp/mysql.socket --database=test

Requirements

OnlineSchemaChange requires

System packages

For Python2

sudo apt-get install python-dev libmysqlclient-dev # Debian / Ubuntu
sudo yum install python-devel mysql-devel # Red Hat / CentOS

For Python3

sudo apt-get install python3-dev # debian / Ubuntu
sudo yum install python3-devel # Red Hat / CentOS

Python requirements * python >= 2.7 * python module: six, pyparsing, MySQLdb

Installing OnlineSchemaChange

Run following command to install dependency

python setup.py install --install-scripts=/usr/local/bin

If you have multiple python version available in your environment, or you don’t want mess up with system’s default python, you can use pyenv and virtualenv

How OnlineSchemaChange works

Check wiki page for more detail, and some advanced usage.

How to contribute

Check this wiki page if you want to contribute to this project.

License

OnlineSchemaChange is BSD-licensed. We also provide an additional patent grant.

Metadata

Release files for online-schema-change 0.0.1.post0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for online-schema-change 0.0.1.post0
File Size Uploaded Provenance Actions
online-schema-change-0.0.1.post0.tar.gz 63.7 kB Without provenance Details for online-schema-change-0.0.1.post0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for online-schema-change 0.0.1.post0
File Interpreter ABI Platform Actions
online_schema_change-0.0.1.post0-py2.py3-none-any.whl Python 2, Python 3 none any Details for online_schema_change-0.0.1.post0-py2.py3-none-any.whl

Total release size: 147.9 kB

Release files / online-schema-change-0.0.1.post0.tar.gz

Download URL online-schema-change-0.0.1.post0.tar.gz
Size 63.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4abc06d83c4ff341fe47e13e02c40bf113616ecc7a52d8bbafe73801b990448b
BLAKE2b-256 checksum
How to use checksums
7c6718f5d663c548e255c00bfe7d905d0f4d1633650ff3d6126b550aeb1d729f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / online_schema_change-0.0.1.post0-py2.py3-none-any.whl

Download URL online_schema_change-0.0.1.post0-py2.py3-none-any.whl
Size 84.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2fdfbd097c17b374bbaeafedf035578f88fcb098716abbbee83e5287345286e9
BLAKE2b-256 checksum
How to use checksums
b5cc5ab17a28d65a0b9caac31ddb1c55532ec0f1d27652455db31c4a00f5c3fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for online-schema-change 0.0.1.post0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1.post0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page