SQL Database Commands - Hsanokklis/2023-2024-Tech-journal GitHub Wiki

MySQL Cheat Sheet

Command Description Example Link
mysql -u root -p Use this command to login into MySQL Server image Link
Data types Data types are what can be used as values in a SQL database table, the table to the right has some examples. image Link
Comments You can input comments into your database tables via #, --, or /* image Link
Literal Values This is a specific value that is directly represetned in a SQL statement. It is fixed value such as a number or a string, that is provided directly in the SQL code. image Link
SHOW DATABASES Use this command to show existing databases image Link
CREATE DATABASE databasename; Use this command to create a database image Link
USE databasename; Use this command to pick the database you want to work with image Link
CREATE TABLE tablename Use this command image Link
DESCRIBE Use this command to show information on all columns of a table. image Link
INSERT INTO databasename(x,y,z) VALUES Use this command to add records into a table image Link
SELECT * FROM databasename; Use this command to display all columns in the database table. The * means `match all columns. image Link
SELECT value FROM database WHERE value='x'; Use this command to select a specific column and row by a certain condition using the WHERE clause. image Link
DELETE FROM databasename Use this command to delete a record from a table. In the example you can use the WHERE clause to delete a record by specifiying the criterion for deletion. image Link
ALTER TABLE databasename ADD value Use this command to add a column. In this example the AFTER clause is used to specify the location of the new column. image Link
ALTER TABLE databasename DROP value Use this command to delete a column in the table. image Link