SQL basics 1: SQL Basics

Source: Internet
Author: User

SQL basics 1: SQL Basics

1. What is SQL?

  • SQL is a structured query language.
  • SQL enables us to access databases
  • SQL is an ANSI standard computer language.

Ii. What can SQL do?

  • SQL queries for Databases
  • SQL can retrieve data from the database
  • SQL inserts new records into the database
  • SQL updates database data
  • SQL can delete records from the database
  • SQL allows you to create a new database.
  • SQL allows you to create a new table in the database.
  • SQL allows you to create stored procedures in a database.
  • SQL allows you to create a view in a database
  • SQL allows you to set permissions for tables, stored procedures, and views.

Iii. SQL syntax

1. database tables

A database usually contains one or more tables. Each table is identified by a name (for example, "customer" or "order "). A table contains records (rows) with data ). The following example shows a table named "Persons:

         
         
         
         
Id LastName FirstName Address City
1 Adams John Oxford Street London
2 Bush George Th Avenue New York
3 Carter Thomas Changan Street Beijing

 

 

 

 

The table above contains three records (each corresponding to one person) and five columns (Id, last name, name, address, and city ).

2. SQL statements

Most of the work you need to execute on the database is completed by SQL statements.

The following statement selects the data in the LastName column from the table:

SELECT LastName FROM Persons

The result set is similar to the following:

LastName
Adams
Bush
Carter

 

 

 

 

** Important: SQL is case insensitive !!

SQL DML and DDL:

SQL can be divided into two parts: data operation language (DML) and Data Definition Language (DDL ).

SQL (Structured Query Language) is the syntax used to execute queries. However, the SQL language also contains the syntax used to update, insert, and delete records.

The query and update commands constitute the DML part of SQL:

SELECT-Retrieve data from a database table

  • UPDATE-Update data in the database table
  • DELETE-Delete data from a database table
  • INSERT-Insert data to a database table

The Data Definition Language (DDL) Section of SQL enables us to create or Delete tables. We can also define indexes (KEYS), define links between tables, and apply constraints between tables.

The most important DDL statements in SQL:

  • CREATE DATABASE-Create a new database
  • ALTER DATABASE-Modify a database
  • CREATE TABLE-Create a new table
  • ALTER TABLE-Change the database table
  • DROP TABLE-Delete a table
  • CREATE INDEX-Create an index (search key)
  • DROP INDEX-Delete An index

 

 

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.