Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of Database Table and SQL statement in SQL

Shulou Source: shulou.com Published: 2022-06-01 13:13:26 10月04日 Update

This article mainly introduces the example analysis of database tables and SQL statements in SQL, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.

Database table

A database usually contains one or more tables. Each table is identified by a name. The table contains records (rows) with data.

Id LastName FirstName Address City1 Adams John Oxford Street London2 Bush George Fifth Avenue New York3 Carter Thomas Changan Street Beijing

Note: a table named "Persons" contains three records (three people) and five columns (Id, last name, first name, address, and city).

SQL statement

Most of the work you need to do on the database is done by SQL statements. For example, select the data of the LastName column from the table:

SELECT LastName FROM Persons

Important matters

SQL is not case-sensitive!

The semicolon after the SQL statement? A semicolon is the standard way to separate each SQL statement in a database system.

Some database systems require a semicolon at the end of each SQL command, while others do not (such as MS Access).

SQL DML and DDL

SQL can be divided into two parts: data manipulation language (DML) and data definition language (DDL).

SQL (structured query language) is the syntax for executing queries, and the SQL language also contains syntax for updating, inserting, and deleting records.

Query and update instructions make up the DML part of SQL:

SELECT-get data from database tables

UPDATE-updates the data in the database table

DELETE-removes data from the database table

INSERT INTO-insert data into the database table

The DDL section of SQL can create or delete tables. You can also define indexes (keys), specify links between tables, and impose constraints between tables.

The most important DDL statement in SQL:

CREATE DATABASE-create a new database

ALTER DATABASE-modify the database

CREATE TABLE-create a new table

ALTER TABLE-change (change) database table

DROP TABLE-Delete the table

CREATE INDEX-create index (search key)

DROP INDEX-Delete the index

Thank you for reading this article carefully. I hope the article "sample Analysis of Database tables and SQL sentences in SQL" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Data database statement article language semicolon index part update query example analysis importance system grammar two between item value interest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Redmi Docker NVidia vpn