Results: 175
CREATE TABLE LIKE
Creates
sdt_prices_unique
table with exactly the same structure as
sdt_prices
table has
CREATE TABLE sdt_prices_unique LIKE sdt_prices
Make existing column UNIQUE
Makes
columnname
column UNIQUE
ALTER TABLE dbname.tablename
ADD UNIQUE (columnname)
INSERT IGNORE INTO
Inserts all rows, ignores rows with
Duplicate key
error
INSERT IGNORE INTO dbname.prices_unique
SELECT * FROM dbname.prices
Lost connection to MySQL server during query
When trying to import database the following problem occurred:
ERROR 2013 (HY000) at line 430: Lost connection to MySQL server during query
Solution to the problem was to increase connection timeout variable by running to following query:
SET GLOBAL connect_timeout = 10;
Disable / enable foreign key checks
First we disable
FOREIGN_KEY_CHECKS
to be able to run queries, then we enable
FOREIGN_KEY_CHECKS
back
SET FOREIGN_KEY_CHECKS=0;
--- Runs some SQL query - for example deleting some rows from a table that has foreign keys
SET FOREIGN_KEY_CHECKS=1;
Select column comment with some other column specifications
Shows details about each column from
decorations
table including column comments
SHOW FULL COLUMNS FROM decorations
Select column comment
Selects
is_optional
column comment which exists in
decorations
table using
information_schema
database
SELECT COLUMN_COMMENT 
FROM information_schema.COLUMNS 
WHERE TABLE_SCHEMA = 'geiger' 
    AND TABLE_NAME = 'decorations' 
    AND COLUMN_NAME = 'is_optional'
Set column comment
Sets new comment for
name
column in
channels
table
ALTER TABLE `channels` CHANGE `name` `name` varchar(255) COMMENT 'name of channel'
Select table comment
Selects comment of
channels
table which exists in the
geiger
database
SELECT table_comment 
FROM INFORMATION_SCHEMA.TABLES 
WHERE table_schema='geiger' 
    AND table_name='channels'
Set table comment
Sets comment for the specified table to make it easy for other developers what the purpose of this table is
ALTER TABLE `the_table_name` comment 'Some text about the table'
Results: 175