SQL DB


4,300+ Sql Stock Photos, Pictures & Royalty-Free Images ... 

I used to religiously install MyPhpAdmin to manage SQL databases but I've actually found it quicker and easier to do some basic things via command line. I am writing a getting started here for reference.

 

Every line ends with a ; which ends the command and executes mysql 

# will start the shell
mysql

# loging in as a user '-u' is for user, '-p' will prompt for pw
mysql -u [LOGIN_USERNAME] -p

# execute query from command line and exit
mysql -e "[SQL QUERY HERE];"

# view existing databases
mysql> SHOW DATABASES;

# Select a database to run queries on
mysql> USE [DATABASE NAME];

# view tables in the selected database
mysql> SHOW TABLES;
# show all info from table
mysql> SELECT * FROM [TABLE_NAME];
# show column in table
mysql> SELECT [COLUMN_NAME} FROM [TABLE_NAME];
# select row
mysql>
SELECT * FROM [DATABASE_NAME] WHERE [COLUMN_HEADING] = '[ROW_VALUE';

Comments

Popular Posts