Step-by-step introduction to databases

Source: Internet
Author: User

Step-by-step introduction to databases
Database Table

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 ).

SQL statement

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

In this tutorial, we will explain various SQL statements for you.

Important

Be sure to remember that SQL is not case sensitive!

What is the semicolon next to an SQL statement?

Some database systems require the use of semicolons at the end of each SQL command. Do not use semicolons in our tutorial.

A semicolon is a standard method used to separate each SQL statement in the database system. In this way, you can execute more than one statement in the same request to the server.

If you are using MS Access and SQL Server 2000, you do not have to use a semicolon after each SQL statement, but some database software requires that you use a semicolon.

SQL dml and DDL can divide SQL 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-obtain data from a database table
  • UPDATE-UPDATE data in the database table
  • DELETE-DELETE data from a database table
  • Insert into-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 DATABASE
  • Create table-CREATE a new TABLE
  • Alter table-Change Database TABLE
  • Drop table-delete a TABLE
  • Create index-create 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.