Database step-by-step primer

Source: Internet
Author: User

Database tables

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

The following example is a table named "Persons":

id lastname firstname address city
1 adams john oxford Street london
2 bush george fifth Avenue new York
3 carter thomas changan Street beijing

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

SQL statements

Most of the work you need to do on the database is done by SQL statements.

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

SELECT LastName from Persons

The result set looks like this:

lastname
adams
bush
carter

In this tutorial, we'll walk you through a variety of different SQL statements.

Important issues

Be sure to remember thatSQL is not case sensitive !

Semicolon after the SQL statement?

Some database systems require semicolons to be used at the end of each SQL command. Semicolons are not used in our tutorials.

Semicolons are the standard way to separate each SQL statement in a database system so that more than one statement can be executed in the same request to the server.

If you are using MS Access and SQL Server 2000, you do not have to use semicolons after each SQL statement, although some database software requirements must use semicolons.

SQL DML and DDL can divide SQL into two parts: Data manipulation Language (DML) and data definition language (DDL).

SQL (Structured Query language) is the syntax for executing queries. However, the SQL language also contains syntax for updating, inserting, and deleting records.

The query and update Directives form the DML portion of SQL:

    • SELECT -get data from a database table
    • Update-updating data in a database table
    • Delete-deletes data from the database table
    • INSERT INTO-inserts data into a database table

The Data definition language (DDL) portion of SQL gives us the ability to create or delete tables. We can also define indexes (keys), specify links between tables, and impose constraints between tables.

The most important DDL statement in SQL:

  • CREATE database-creating new databases
  • alter database-Modify Databases
  • CREATE TABLE-Creates a new table
  • ALTER TABLE -Change (change) database table
  • Drop Table-delete tables
  • CREATE index-Creating indexes (search key)
  • Drop Index-delete indexes

Database step-by-step primer

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.