GithubHelp home page GithubHelp logo

sql-cheat-basic's Introduction

SQL CHEAT

Create & use DATABASE

CREATE DATABASE nom_de_la_bdd;
USE nom_de_la_bdd;

List all Databases

SHOW DATABASES;

Delete Database

DROP DATABASE nom_de_la_bdd;

TABLES

Create table

CREATE TABLE nom_de_la_table (
    id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
    name VARCHAR(150) NOT NULL,
    age INT NOT NULL,
    is_visible BOOL NULL,
    address TEXT NULL,
    birthday DATE NULL
);

Display structure table

DESCRIBE nom_de_la_table;

Display values from table

SELECT * FROM nom_de_la_table;

List all Tables

SHOW TABLES;

Insert value(s)

INSERT INTO nom_de_la_table (name, age, is_visible, address, birthday) VALUES ('plop', 15, 1, 'la fayette 75010', '1985-01-01'), (Other values) , (Other values);

Change structure of table

ALTER TABLE nom_de_la_table ADD nom_colomn TYPE OPTION;
Exemple pour ajouter une colonne :
ALTER TABLE nom_de_la_table ADD zipcode INT NOT NULL;

Update value

UPDATE nom_de_la_table SET nom_colomn='value';
UPDATE nom_de_la_table SET nom_colomn='value' WHERE id=1;

Delete value

DELETE FROM nom_de_la_table WHERE *condition*;
DELETE FROM nom_de_la_table WHERE id=1;

Delete all values from table

TRUNCATE TABLE nom_de_la_table;

Delete table

DROP TABLE nom_de_la_table;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.