Skip to content

Instantly share code, notes, and snippets.

@theWhiteFox
Created August 9, 2016 09:15
Show Gist options
  • Select an option

  • Save theWhiteFox/756846a4aabde745a2bbfaee4097e410 to your computer and use it in GitHub Desktop.

Select an option

Save theWhiteFox/756846a4aabde745a2bbfaee4097e410 to your computer and use it in GitHub Desktop.
SQL commands
-- login to my local MySql server
mysql -u root -p
-- password:
SHOW databases;
CREATE DATABASE db_name;
USE db_name;
SHOW tables;
CREATE TABLE table_name (
id int(10) NOT NULL AUTO_INCREMENT,
foreign_key_id int(10),
name varchar(255),
date timestamp,
PRIMARY KEY(id),
FOREIGN KEY(foreign_key_id) REFERENCES table_name(foreign_key_id)
);
RENAME TABLE `memebers` TO `members`
UPDATE `books` SET `author`='Luke Wroblewski', `title`='Mobile First', `link`='http://www.abookapart.com/products/mobile-first', `image`='images/mobile_first.jpg' WHERE `book_id`=2;
create table posts(post_id INT AUTO_INCREMENT, title varchar(255), body text, PRIMARY KEY(post_id));
describe posts
INSERT INTO posts (title, body) VALUES('PHP is\'t too hard', 'Here is the body of the second post');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment