databaseSQL

Connecting to mysql

mysql -u $username -p$password

<aside> 💡

There shouldn't be any spaces between '-p' and the password.

</aside>

Connecting to a specified host

mysql -u $username -h $hostname -P $port -p$password

Creating a Database

CREATE DATABASE $databsename;
SHOW DATABASES;

Tables

CREATE TABLE $tablename (
		id INT,
    username VARCHAR(100),
    password VARCHAR(100),
    date_of_joining DATETIME
		);

shows table structure

INSERT Statement

SELECT Statement

DROP Statement

ALTER Statement

We can also change a column's datatype with MODIFY:

UPDATE Statement

Last updated