Skip to content

Add essential sections to MySQL: Alter, Indexes, and Transactions#442

Open
michaelmjhhhh wants to merge 1 commit intoLeCoupa:masterfrom
michaelmjhhhh:michaelmjhhhh-update-mysql-cheatsheet
Open

Add essential sections to MySQL: Alter, Indexes, and Transactions#442
michaelmjhhhh wants to merge 1 commit intoLeCoupa:masterfrom
michaelmjhhhh:michaelmjhhhh-update-mysql-cheatsheet

Conversation

@michaelmjhhhh
Copy link
Copy Markdown

Hi there!

I've enhanced the MySQL cheat sheet by adding three essential sections that are crucial for day-to-day database management and development:

  1. Altering Table Structure: Commands for adding, modifying, renaming, and dropping columns/tables.
  2. Indexes (Performance Tuning): Added CREATE INDEX, SHOW INDEX, and the EXPLAIN command for query analysis.
  3. Transactions (Data Integrity): Added START TRANSACTION, COMMIT, and ROLLBACK for managing database consistency.

I have strictly followed the existing formatting style (using # ***** separators and maintaining consistent comment spacing) to ensure it blends perfectly with the current document. This update makes the cheat sheet more comprehensive for developers. Hope this helps the community!

I have enhanced the MySQL cheat sheet by adding three essential sections that were previously missing:

1. Altering Table Structure: Commands for adding, modifying, renaming, and dropping columns/tables.
2. Indexes (Performance Tuning): Added CREATE INDEX, SHOW INDEX, and the EXPLAIN command for query analysis.
3. Transactions (Data Integrity): Added START TRANSACTION, COMMIT, and ROLLBACK for managing database consistency.
Copilot AI review requested due to automatic review settings March 21, 2026 06:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds commonly used MySQL DDL, indexing, and transaction commands to the existing databases/mysql.sh cheat sheet to make it more complete for day-to-day database work.

Changes:

  • Added an “Altering Table Structure” section with ALTER TABLE examples.
  • Added an “Indexes (Performance Tuning)” section with index management and EXPLAIN.
  • Added a “Transactions (Data Integrity)” section with basic transaction control commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

START TRANSACTION; # Begin a new transaction
COMMIT; # Save all changes made during the transaction
ROLLBACK; # Undo all changes if an error occurs before commit
SET AUTOCOMMIT = 0; # Disable automatic commits for the current session
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SET AUTOCOMMIT = 0; can leave the session in manual-commit mode after the example runs, which may cause unexpected long-running transactions/locks if the user forgets to re-enable it. Consider either (a) adding a companion SET AUTOCOMMIT = 1; line in this section or (b) updating the comment to explicitly warn to turn autocommit back on when finished (and/or place it before START TRANSACTION to show intended ordering).

Suggested change
SET AUTOCOMMIT = 0; # Disable automatic commits for the current session
SET AUTOCOMMIT = 0; # Disable automatic commits for the current session
SET AUTOCOMMIT = 1; # Re-enable automatic commits after finishing manual transactions

Copilot uses AI. Check for mistakes.
# Altering Table Structure
# *****************************************************************************

ALTER TABLE table_name ADD column_name datatype; # Add a new column to an existing table
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the other ALTER examples (which explicitly use ... COLUMN ...), consider using ADD COLUMN here as well. It also makes the intent unambiguous for readers skimming the cheat sheet.

Suggested change
ALTER TABLE table_name ADD column_name datatype; # Add a new column to an existing table
ALTER TABLE table_name ADD COLUMN column_name datatype; # Add a new column to an existing table

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants