Microsoft Visual Basic 6 (Database Programming SQL)
Microsoft Visual Basic 6 (Database Programming SQL)
Microsoft Visual Basic 6 (Database Programming SQL)
Introduction to SQL
SQL is a standard language for accessing and manipulating databases.
What is SQL?
• SQL stands for Structured Query Language
• SQL lets you access and manipulate databases
• SQL is an ANSI (American National Standards Institute) standard
• Keep in mind SQL is not case sensitive
What Can SQL do?
• SQL can execute queries against a database
• SQL can retrieve data from a database
• SQL can insert, update and delete records in a database
• SQL can create new databases
• SQL can create new tables in a database
SQL DML and DDL Statements
SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data
Definition Language (DDL).
The query and update commands form the DML part of SQL:
• SELECT - extracts data from a database
• UPDATE - updates data in a database
• DELETE - deletes data from a database
• INSERT INTO - inserts new data into a database
The DDL part of SQL permits database tables to be created or deleted. It also define
indexes (keys), specify links between tables, and impose constraints between tables. The
most important DDL statements in SQL are:
• CREATE DATABASE - creates a new database
• ALTER DATABASE - modifies a database
• CREATE TABLE - creates a new table
• ALTER TABLE - modifies a table
• DROP TABLE - deletes a table
• CREATE INDEX - creates an index (search key)
• DROP INDEX - deletes an index
The SQL SELECT Statement
The SELECT statement is used to select data from a database.The result is stored in a
result table, called the result-set.
SQL SELECT Syntax
SELECT * or column_name(s) FROM table_name
SQL DISTINCT Clause
The DISTINCT keyword can be used to elimate the duplicate values.
An SQL SELECT Example
1. SELECT * FROM Employee (select all column from table)
2. SELECT Emp_Code,Emp_Name FROM Employee
3. SELECT Distinct Emp_Name FROM Employee