Tables And SQL basics

11,540 views

Published on

it is very basic introduction to SQL statements, using access syntax

2 Comments
8 Likes
Statistics
Notes
No Downloads
Views
Total views
11,540
On SlideShare
0
From Embeds
0
Number of Embeds
6,045
Actions
Shares
0
Downloads
636
Comments
2
Likes
8
Embeds 0
No embeds

No notes for slide
  • Tables And SQL basics

    1. 1. TABLES AND SQL Controlling Tables Programmatically By: Amit Kumar Singh
    2. 2. Tables <ul><li>2 Dimensional matrix </li></ul><ul><li>Unique name </li></ul>
    3. 3. SQL <ul><li>S tructured Q uery L anguage </li></ul><ul><li>ANSI standard computer language </li></ul><ul><li>Allows you to access a database </li></ul><ul><li>Execute queries, retrieve, insert, delete, update records </li></ul><ul><li>Freedom from intricacy & details of database softwares. </li></ul><ul><li>EASY TO LEARN </li></ul>
    4. 4. Creating Tables <ul><li>CREATE TABLE table_name </li></ul><ul><li>( column_name1 data_type , column_name2 data_type , ....... ) ; </li></ul><ul><li>Example, </li></ul><ul><li>CREATE TABLE Person   ( </li></ul><ul><li>LastName varchar(30), FirstName varchar, Address varchar, Age int(3)   ) ; </li></ul><ul><li>Create Table tbldemo </li></ul><ul><li>( Name text(30), </li></ul><ul><li>Age integer, </li></ul><ul><li>Gender text(1) </li></ul><ul><li>); </li></ul><ul><li>Data type depends on the Database management software you are using </li></ul>
    5. 5. SQL ALTER TABLE <ul><li>ALTER TABLE table_name ADD COLUMN _name datatype </li></ul><ul><li>ALTER TABLE table_name DROP COLUMN column_name </li></ul><ul><li>Example, </li></ul><ul><li>ALTER TABLE tbldemo ADD COLUMN date_of_birth datetime </li></ul><ul><li>ALTER TABLE tbldemo DROP COLUMN marks; </li></ul>
    6. 6. SQL INSERT <ul><li>INSERT INTO table_name VALUES (value1, value2,....) </li></ul><ul><li>INSERT INTO table_name (column_name1,column_name2,...) VALUES (value1, value2,....) </li></ul><ul><li>Example, </li></ul><ul><li>INSERT INTO tbldemo VALUES ( 'Amit', 22, 'm', #8/22/1982#, 27474017 ) ; </li></ul><ul><li>INSERT INTO tbldemo ( Name, Age, Gender, date_of_birth ) </li></ul><ul><li>VALUES ('Preeti', 22, 'f', #2/18/1982#); </li></ul>
    7. 7. SQL SELECT <ul><li>SELECT column_name(s) FROM table_name </li></ul><ul><li>SELECT * FROM table_name </li></ul><ul><li>SELECT * INTO new_table_name FROM original_table_name </li></ul><ul><li>SELECT column_name(s) FROM table_name WHERE condition </li></ul><ul><li>Example, </li></ul><ul><li>SELECT Name FROM tbldemo WHERE GENDER='f'; </li></ul>
    8. 8. SQL UPDATE <ul><li>UPDATE table_name SET column_name=new_value [, column_name=new_value] WHERE column_name=some_value ; </li></ul><ul><li>Example, </li></ul><ul><li>UPDATE tbldemo SET phone_no = 22523250 WHERE name='ShriRam'; </li></ul>
    9. 9. SQL DELETE <ul><li>DELETE FROM table_name WHERE condition </li></ul><ul><li>DELETE FROM table_name ( Note: Deletes the entire table!!) </li></ul><ul><li>Example, </li></ul><ul><li>DELETE FROM tbldemo WHERE Gender='f'; </li></ul>
    10. 10. SQL DROP TABLE <ul><li>DROP TABLE table_name </li></ul><ul><li>Example, </li></ul><ul><li>DROP TABLE tbldemo; </li></ul>
    11. 11. More SQL… <ul><li>http://www.w3schools.com/sql/default.asp </li></ul><ul><li>http://w3.one.net/~jhoffman/sqltut.htm </li></ul>

    ×