List of MySQL sentences for programming beginners * Personal memo

List of MySQL sentences for programming beginners * Personal memo

Describe the memo currently being studied Please comment if you have any corrections or advice.

setup

action SQL statement
Connect to MySQL mysql -u root -p
MySQL disconnect exit
change Password ALTER USER 'root'@'localhost' IDENTIFIED BY 'New password';

Database operation

action SQL statement
Creating a database CREATE DATABASE database name default character set utf8;
Delete database DROP DATABASE database name;
Check the list of databases show databases;
Select database to operate USE database name;

Table operation

action SQL statement
Creating a table CREATE TABLE database name.Table name you want to create(●);
Delete table DROP TABLE database name.Table name you want to create;
Check the list of tables show tables;
Confirmation of table design describe books;
action SQL statement
ID column ID INT AUTO_INCREMENT NOT NULL PRIMARY KEY
String column Column name VARCHAR(Maximum number of characters)
Integer column Column name INT
Registration date and time automatic registration column Column name TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP

CRUD operation

action SQL statement
Data creation INSERT INTO table name(Column 1,Column 2, ...) VALUES (Value 1,Value 2, ...);
Data acquisition SELECT column name FROM table name;
Data update UPDATE table name SET column name 1=Value 1,Column name 2=Value 2, …;
Delete data DELETE FROM table name;

Other

Operation example SQL statement
WHERE clause example CRUD statement WHERE column name=value;
ORDER BY clause example CRUD statement ORDER BY Sorting criteria column
Analysis function SELECT function(Column name)FROM table name;
Join table INNER JOIN table name ON condition

Recommended Posts

List of MySQL sentences for programming beginners * Personal memo
List of beginners (List) memo
List of frequently used Java instructions (for beginners and beginners)
[For beginners] Summary of java constructor
A list of rawValues for UITextContentType.
[Personal memo] About button (GUI) operation of Docker Desktop for Windows
Sort in List, for personal notes
Recommended learning method for programming beginners
List of alternative distributions for CentOS
I wrote EX25 of AtCoder Programming Guide for beginners (APG4b) in java.
[For programming beginners] What is a method?
List of point cuts for making finer point cuts
List of download destinations for oracle java
Explanation of Ruby on rails for beginners ①
[Personal memo] A small story about CPUs settings of Docker Desktop for Windows
A brief summary of Bootstrap features for beginners
List of libraries useful for ios application development
A collection of simple questions for Java beginners
[Introduction to Java] Basics of java arithmetic (for beginners)
Awareness of object-oriented programming for half a year