Databases

From Cheatsheet
Revision as of 21:49, 28 July 2023 by Patrick (talk | contribs) (Created page with "Cheatsheets == MYSQL+MARIADB == <syntaxhighlight lang="bash"> # Log into the MySQL CLI mysql -u root -p # Show all tables in the database SHOW TABLES; # Exit the MySQL CLI exit </syntaxhighlight> == Postgres == <syntaxhighlight lang="bash"> # Log into the Postgres CLI psql # List all databases \l # Connect to a database -d mydatabase -U databaseuser –W # Switch to the new database connection \c mydatabase databaseuser # List all tables \...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


MYSQL+MARIADB

# Log into the MySQL CLI
mysql -u root -p

# Show all tables in the database
SHOW TABLES;

# Exit the MySQL CLI
exit

Postgres

# Log into the Postgres CLI
psql

# List all databases
\l

# Connect to a database
-d mydatabase -U databaseuser –W

# Switch to the new database connection
\c mydatabase databaseuser

# List all tables
\dt

# Quit the Postgres CLI
\q