Skip to content

stepanenko/sql-info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL

Q A
First appeared 1974
Paradigm Declarative
Family Query language
Typing discipline Static, strong
Designed by Donald D. Chamberlin, Raymond F. Boyce

Examples:

Database creation:

CREATE DATABASE mydatabase;

Table creation:

CREATE TABLE users (
  id INT PRIMARY KEY,
  username VARCHAR(50),
  email VARCHAR(100)
);

Data Insertion:

INSERT INTO users (id, username, email)
VALUES (1, 'john_doe', 'john@example.com');

Data Querying:

SELECT * FROM users;

Data Filtering:

SELECT * FROM users WHERE username = 'john_doe';

Data Sorting and Limiting:

SELECT * FROM users ORDER BY username ASC LIMIT 10;

Data Aggregation:

SELECT COUNT(*) FROM users; # Use aggregate functions like COUNT, SUM, AVG, MIN, and MAX for data analysis

Data Updating:

UPDATE users SET email = 'john.doe@example.com' WHERE id = 1;

Data Deletion:

DELETE FROM users WHERE id = 1;

Table Joining (used to combine rows from two or more tables based on a related column):

SELECT users.username, orders.order_id
FROM users
INNER JOIN orders ON users.id = orders.user_id;

Table Editing:

ALTER TABLE table_name ADD column_name datatype;

Table Deletion:

DROP TABLE table_name;

List Databases:

SHOW DATABASES; # Displays a list of all the available databases

SHOW SCHEMAS; # an alternate for the SHOW DATABASES statement

Use Database:

USE database_name; # Specifies which database to use

List Tables:

SHOW TABLES; # Displays a list of tables in the current database

More at https://www.w3schools.com/sql/sql_ref_mysql.asp

About

Some notes about SQL

Topics

Resources

Stars

Watchers

Forks