0% found this document useful (0 votes)
19 views11 pages

Tables and SQL Basics 1194094490656425 3

This document discusses tables and SQL. It explains that tables are 2D matrices with unique names, and SQL is a standard language for accessing and manipulating data in databases. It provides the syntax for common SQL statements like CREATE TABLE, ALTER TABLE, INSERT, SELECT, UPDATE, DELETE, and DROP TABLE with examples. These statements allow you to create tables, add/drop columns, insert/select/update/delete data, and drop tables programmatically. Additional online SQL tutorials are also referenced.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views11 pages

Tables and SQL Basics 1194094490656425 3

This document discusses tables and SQL. It explains that tables are 2D matrices with unique names, and SQL is a standard language for accessing and manipulating data in databases. It provides the syntax for common SQL statements like CREATE TABLE, ALTER TABLE, INSERT, SELECT, UPDATE, DELETE, and DROP TABLE with examples. These statements allow you to create tables, add/drop columns, insert/select/update/delete data, and drop tables programmatically. Additional online SQL tutorials are also referenced.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

TABLES AND SQL

Controlling Tables Programmatically

By: Amit Kumar Singh

Tables
2 Dimensional matrix
Unique name

SQL

Structured Query Language

ANSI standard computer language


Allows you to access a database
Execute queries, retrieve, insert, delete, update records
Freedom from intricacy & details of database softwares.
EASY TO LEARN

Creating Tables

CREATE TABLE table_name


( column_name1 data_type, column_name2 data_type, ....... ) ;

Example,
CREATE TABLE Person (
LastName varchar(30), FirstName varchar, Address varchar, Age int(3) ) ;

Create Table tbldemo


( Name text(30),
Age integer,
Gender text(1)
);

Data type depends on the Database management software you are using

SQL ALTER TABLE

ALTER TABLE table_name ADD COLUMN_name datatype


ALTER TABLE table_name DROP COLUMN column_name

Example,
ALTER TABLE tbldemo ADD COLUMN date_of_birth datetime
ALTER TABLE tbldemo DROP COLUMN marks;

SQL INSERT

INSERT INTO table_name VALUES (value1, value2,....)


INSERT INTO table_name
(column_name1,column_name2,...)VALUES(value1, value2,....)

Example,

INSERT INTO tbldemo VALUES ('Amit', 22, 'm', #8/22/1982#, 27474017);

INSERT INTO tbldemo ( Name, Age, Gender, date_of_birth )


VALUES ('Preeti', 22, 'f', #2/18/1982#);

SQL SELECT

SELECT column_name(s) FROM table_name


SELECT * FROM table_name
SELECT * INTO new_table_name FROM original_table_name

SELECT column_name(s) FROM table_name WHERE condition

Example,

SELECT Name FROM tbldemo WHERE GENDER='f';

SQL UPDATE

UPDATE table_name
SET column_name=new_value
[, column_name=new_value]
WHERE column_name=some_value ;

Example,

UPDATE tbldemo SET phone_no = 22523250 WHERE name='ShriRam';

SQL DELETE

DELETE FROM table_name WHERE condition

DELETE FROM table_name


(Note: Deletes the entire table!!)

Example,

DELETE FROM tbldemo WHERE Gender='f';

SQL DROP TABLE

DROP TABLE table_name

Example,

DROP TABLE tbldemo;

More SQL
http://www.w3schools.com/sql/default.asp
http://w3.one.net/~jhoffman/sqltut.htm

You might also like