Skip to content

Instantly share code, notes, and snippets.

@pphamnham
Last active August 22, 2016 13:08
Show Gist options
  • Select an option

  • Save pphamnham/017ddc6f4a6c257a8de73b9fc1fccdbd to your computer and use it in GitHub Desktop.

Select an option

Save pphamnham/017ddc6f4a6c257a8de73b9fc1fccdbd to your computer and use it in GitHub Desktop.

#SQL #GENERAL CONCEPT

SELECT THE EXISTING DATABASE

USE name_database; ###DISPLAY EXISTING TABLES SHOW TABLES; ###CREATE NEW TABLE

CREATE TABLE students(
id INT NOT NULL PRIMARY KEY,
name VARCHAR(40) NOT NULL,
class VARCHAR(20),
age INT);

Using AutoIncrement to make sure the key automatically update

CREATE TABLE subjects (
subjectid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50) NOT NULL
); 

###DESCRIBE STRUCTURE OF THE TABLE DESCRIBE students ###DELETE DROP TABLE students ###ADD DATA

INSERT INTO students VALUES (XX,XX,XX)
INSERT INTO students(id, firstname, lastname) VALUES (xx,xx,xx);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment