Add essential sections to MySQL: Alter, Indexes, and Transactions#442
Add essential sections to MySQL: Alter, Indexes, and Transactions#442michaelmjhhhh wants to merge 1 commit intoLeCoupa:masterfrom
Conversation
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.
There was a problem hiding this comment.
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 TABLEexamples. - 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 |
There was a problem hiding this comment.
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).
| 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 |
| # Altering Table Structure | ||
| # ***************************************************************************** | ||
|
|
||
| ALTER TABLE table_name ADD column_name datatype; # Add a new column to an existing table |
There was a problem hiding this comment.
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.
| 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 |
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:
CREATE INDEX,SHOW INDEX, and theEXPLAINcommand for query analysis.START TRANSACTION,COMMIT, andROLLBACKfor 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!