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.