Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Friday, January 26, 2018

MySql Cheat Sheet



Login to MySQL
$ mysql –u root –p 
Password: cloudera 
(password will not visible but we have to type)

Show databases;
mysql> show databases;

Use Database
 $ use <database name> Ex:$ use retail_db;

Exit from mysql
mysql> quit;

Working with Database

Create database
create database [If not exists] testdatabase;

Drop database
drop database [If exists] testdatabase;

Create table or temporary table

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table(
   key type(size) NOT NULL PRIMARY KEY AUTO_INCREMENT,
   c1 type(size) NOT NULL,
   c2 type(size) NULL,
   ...
);