Skip to content

Instantly share code, notes, and snippets.

@shams-ali
Last active July 30, 2016 20:13
Show Gist options
  • Save shams-ali/f4158dfb2f5f62b96f4a8b6e35d3c22c to your computer and use it in GitHub Desktop.
Save shams-ali/f4158dfb2f5f62b96f4a8b6e35d3c22c to your computer and use it in GitHub Desktop.
SQL Commands
//create db
CREATE DATABASE db_name;
//create table
CREATE TABLE table_name
(
col1_name datatype,
col2_name datatype,
col3_name datatype,
...
);
//drop table
DROP TABLE table_name;
//datatypes
int, varchar(length)
//get data
SELECT col1_name, col2_name, ... FROM table_name WHERE col_name = col_value ORDER BY col_name order_how;
//update table
UPDATE table_name SET col_name = new_value WHERE col_name = col_value;
//insert
INSERT into table_name (col1_name, col2_name, col3_name...) VALUES (value1, value2, value3...);
//aggregate functions
count, sum, avg, max, min
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment