| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

MysqlNotes

Page history last edited by David B 11 years, 7 months ago

Mysql Cheat Sheet

 

Database:      show databases;
               create database dbname;
               use database dbname;
 
Tables:        show tables;
Create:     
 
create table tablename (id char(2), date DATE, norooms INT(5));
 
Example, including key and auto-increment     
 
create table requests (id int auto_increment, name char(255), business char(255), primary key (id));
 
-or-
 
create table county (id int(11) not null auto_increment primary key,name char(100));
 
create table events (id int(11) not null auto_increment, title varchar(50), loc varchar(50), desc1 char(255), desc2 char(255), url char(100), directions char(255), address char(255), phone char(100), primary key (id));
 
Information:     describe tablename;
 
Change:          alter table dist add column (url char(100));
 
Add auto-increment:     alter table ids modify column id int(11) auto_increment primary key;
 
Change column name (rename column):    alter table buyers change column hotel hotelid int;
 
Add column after specific column:    alter table sites add column page char(30) after id;
 
Add column at start:    alter table sitetype add column tid char(4) first;
 
Query
=====
 
Basic query:     select * from tablename;
 
Highest value from int type column:    SELECT MAX(id) as id from contacts

Comments (0)

You don't have permission to comment on this page.