Last active
January 3, 2019 14:57
-
-
Save urbansky/8ddd867f267aec86161339bc190f54b7 to your computer and use it in GitHub Desktop.
Most commonly used MySQL commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Standard select | |
SELECT id, price FROM table_name; | |
-- Check not NULL | |
SELECT id, price FROM table_name WHERE consumer IS NOT NULL; | |
-- Update | |
UPDATE table_name SET price = 1; | |
-- Delete data | |
DELETE FROM Store_Information WHERE Store_Name = 'Los Angeles'; | |
-- Show table rows | |
DESCRIBE table_name; | |
-- Delete column | |
ALTER TABLE table_name DROP row_name; | |
-- Insert | |
INSERT INTO kunden (name, adresse) VALUES ('Hans Meier', 'Wuppernweg 19') | |
-- Nutzer erstellen und gleichzeitig Zugang zu einer Datenbank gewähren | |
GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' IDENTIFIED BY 'some_pass' WITH GRANT OPTION; | |
-- Drop user | |
DROP USER 'monty'@'%'; | |
-- Change db engine | |
alter table card ENGINE=INNODB; | |
-- Rename column | |
ALTER TABLE agent_groups CHANGE COLUMN agent_group_id group_id bigint(20) NOT NULL; | |
-- Reset auto increment counter | |
ALTER TABLE ticket AUTO_INCREMENT = 1; | |
-- Replace Strings | |
UPDATE tablename SET column = REPLACE(column, "aaa", "bbb"); | |
-- Dump wieder einspielen | |
mysql -u -p --database=webapp < webapp.sql | |
-- Eine Datenbank exportieren: | |
mysqldump --opt -u -p webapp > webapp.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment