Jump to content

Recommended Posts

Posted

SQL - Accessing The Databases!

 

SQL-Injection-Attack.jpg

 


 

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.

 


 

What Can SQL do?

 

  • SQL can execute queries against a database.
  • SQL can retrieve data from a database.
  • SQL can insert records in a database.
  • SQL can update records in a database.
  • SQL can delete records from a database.
  • SQL can create new databases.
  • SQL can create new tables in a database.
  • SQL can create stored procedures in a database.
  • SQL can create views in a database.
  • SQL can set permissions on tables, procedures, and views.

 


 

SQL is a Standard - BUT....

 

Although SQL is an ANSI (American National Standards Institute) standard, there are many different versions of the SQL language.

 

However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.

 

Note: Most of the SQL database programs also have their own proprietary extensions in addition to the SQL standard!

 


 

SQL Statements.

 

Most of the actions you need to perform on a database are done with SQL statements.

 

The following SQL statement will select all the records in the "Persons" table:

 

SELECT * FROM Persons

 


 

SQL DML and DDL.

 

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 defines indexes (keys), specifies links between tables, and imposes 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 column_name(s)
FROM table_name

 

and

 

SELECT * FROM table_name

 

lamp.gifNote: SQL is not case sensitive. SELECT is the same as select.

 

The INSERT INTO Statement

 

SQL INSERT INTO Syntax

 

It is possible to write the INSERT INTO statement in two forms.

 

The first form doesn't specify the column names where the data will be inserted, only their values:

 

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

 

The UPDATE Statement

 

The UPDATE statement is used to update existing records in a table.

 

SQL UPDATE Syntax

 

UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value

 

Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated!

 

The DELETE Statement

 

The DELETE statement is used to delete rows in a table.

 

SQL DELETE Syntax

 

DELETE FROM table_name
WHERE some_column=some_value

 

Note: Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted!

 

SQL Tutorial with Video Version:

 

 


 

Have fun, and wish you good practice!

 

 

  • 2 weeks later...
  • 1 month later...
  • 2 weeks later...
Posted

Thanks! I would be greatful, if this share be stickied.

its not really needed, thx a lot for that share

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...