Pages

Sunday, July 10, 2011

SQL - DML

SQL to insert data into a table

insert into books (isbn, title, authors) values ('978-0-596-00920-5', 'Head First Java', 'Kathy Sierra, Bert Bates');

SQL to select data based on a column value

select * from books where title='Head First Java';

Saturday, July 9, 2011

SQL - DDL

This post contains a collection of SQL DDL (Data Definition Language) statements.

DDL or Data Definition Language consists of SQL statements which create, drop, or alter a table.

Adding a column in a table:

alter table books add column author varchar(100);

Dropping a column from a table:

alter table books drop column author;

b


MySql Commands

Command to show all database schema in your application

show databases;

Command to switch to a particular database

use bookshop;

Command to show all the tables in a databse (you will have to issue an appropriate 'use' command to switch to that database)

show tables;