SQL Learning 1 Beginner

Source: Internet
Author: User
Tags db2 ibm db2 sorts

---restore content starts---

SqlTutorials

SQL is the standard computer language for accessing and working with databases.

What is SQL?
    • SQL, which refers to the Structured Query language, is the full name of structured query Language.
    • SQL allows you to access and manipulate the database.
    • SQL is a computer language of ANSI (American National Standards Institute United States Standardization Organization) standard.
What can SQL do?
    • SQL database-oriented query execution
    • SQL can retrieve data from the database
    • SQL can insert new records in the database
    • SQL can update data in a database
    • SQL to delete records from the database
    • SQL to create a new database
    • SQL to create a new table in the database
    • SQL can create stored procedures in the database
    • SQL to create views in the database
    • SQL can set permissions for tables, stored procedures, and views
SQL is a standard-but ...

Although SQL is a computer language of ANSI (American National Standards Institute United States Standardization Organization), there are still many different versions of the SQL language.

However, to be compatible with ANSI standards, they must collectively support some of the main commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE, and so on) in a similar way.

Using SQL in your site

To create a Web site that displays data from a database, you need to:

    • RDBMS database programs (such as MS Access, SQL Server, MySQL)
    • Use a server-side scripting language, such as PHP or ASP
    • Use SQL to get the data you want
    • Using HTML/CSS
Rdbms

RDBMS refers to the relational database management system, the full name of relational databases Management system.

The RDBMS is the foundation of SQL and is also the foundation of all modern database systems, such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

Data in an RDBMS is stored in a database object called a table.

A table is a collection of related data items that consists of columns and rows.

SqlGrammarDatabase tables

A database typically contains one or more tables. Each table is identified by a name (for example: "Websites"), and the table contains records (rows) with data.

Please remember ...
    • SQL is not case sensitive: Select is the same as select.
Semicolon after the SQL statement?

Some database systems require semicolons to be used at the end of each SQL statement.

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

Some of the most important SQL commands
    • SELECT -Extract data from the database
    • Update-Updates the data in the database
    • Delete-deletes data from the database
    • INSERT INTO-inserts new data into the database
    • 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
SQL SELECT Statement

The SELECT statement is used to select data from the database.

The result is stored in a result table, called the result set.

Navigation in result sets

Most database software systems allow the use of programming functions to navigate the result set, such as: Move-to-first-record, Get-record-content, Move-to-next-record, and so on.

SqlSELECT DISTINCT Statement

The SELECT DISTINCT statement is used to return only different values.

In a table, a column may contain multiple duplicate values, and sometimes you might want to list only different (distinct) values.

The DISTINCT keyword is used to return only different values.

SqlWHERE clause

The WHERE clause is used to filter records. The WHERE clause is used to extract records that meet the specified criteria.

Text fields vs. numeric fields

SQL uses single quotation marks to wrap text values (most database systems also accept double quotes).

Operators in the WHERE clause

The following operators can be used in the WHERE clause:

operator Description
= Equals
<> Not equal to. Note: in some versions of SQL, this operator can be written in! =
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
Between Within a range
Like Search for a pattern
Inch Specify multiple possible values for a column
Sqland & OR operators

The and & OR operators are used to filter records based on more than one condition.

If both the first condition and the second condition are true, the AND operator displays a record.

If only one of the first and second conditions is true, the OR operator displays a record.

SqlORDER by keyword

The ORDER BY keyword is used to sort the result set.

The ORDER BY keyword is used to sort the result set by one column or multiple columns.

The order by keyword sorts records by default in ascending order. If you need to sort records in descending order, you can use the DESC keyword.

SqlINSERT into statementThe INSERT INTO statement is used to insert a new record into the table. SQL INSERT into syntax

The INSERT into statement can be written in two ways.

The first form does not need to specify the column name to insert the data, just provide the inserted value: The second form needs to specify the column name and the value to be inserted:

Did you notice that we didn't insert any numbers into the ID field?
The ID column is automatically updated, and each record in the table has a unique number.

---restore content ends---

SqlTutorials

SQL is the standard computer language for accessing and working with databases.

What is SQL?
    • SQL, which refers to the Structured Query language, is the full name of structured query Language.
    • SQL allows you to access and manipulate the database.
    • SQL is a computer language of ANSI (American National Standards Institute United States Standardization Organization) standard.
What can SQL do?
    • SQL database-oriented query execution
    • SQL can retrieve data from the database
    • SQL can insert new records in the database
    • SQL can update data in a database
    • SQL to delete records from the database
    • SQL to create a new database
    • SQL to create a new table in the database
    • SQL can create stored procedures in the database
    • SQL to create views in the database
    • SQL can set permissions for tables, stored procedures, and views
SQL is a standard-but ...

Although SQL is a computer language of ANSI (American National Standards Institute United States Standardization Organization), there are still many different versions of the SQL language.

However, to be compatible with ANSI standards, they must collectively support some of the main commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE, and so on) in a similar way.

Using SQL in your site

To create a Web site that displays data from a database, you need to:

    • RDBMS database programs (such as MS Access, SQL Server, MySQL)
    • Use a server-side scripting language, such as PHP or ASP
    • Use SQL to get the data you want
    • Using HTML/CSS
Rdbms

RDBMS refers to the relational database management system, the full name of relational databases Management system.

The RDBMS is the foundation of SQL and is also the foundation of all modern database systems, such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

Data in an RDBMS is stored in a database object called a table.

A table is a collection of related data items that consists of columns and rows.

SqlGrammarDatabase tables

A database typically contains one or more tables. Each table is identified by a name (for example: "Websites"), and the table contains records (rows) with data.

Please remember ...
    • SQL is not case sensitive: Select is the same as select.
Semicolon after the SQL statement?

Some database systems require semicolons to be used at the end of each SQL statement.

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

Some of the most important SQL commands
    • SELECT -Extract data from the database
    • Update-Updates the data in the database
    • Delete-deletes data from the database
    • INSERT INTO-inserts new data into the database
    • 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
SQL SELECT Statement

The SELECT statement is used to select data from the database.

The result is stored in a result table, called the result set.

Navigation in result sets

Most database software systems allow the use of programming functions to navigate the result set, such as: Move-to-first-record, Get-record-content, Move-to-next-record, and so on.

SqlSELECT DISTINCT Statement

The SELECT DISTINCT statement is used to return only different values.

In a table, a column may contain multiple duplicate values, and sometimes you might want to list only different (distinct) values.

The DISTINCT keyword is used to return only different values.

SqlWHERE clause

The WHERE clause is used to filter records. The WHERE clause is used to extract records that meet the specified criteria.

Text fields vs. numeric fields

SQL uses single quotation marks to wrap text values (most database systems also accept double quotes).

Operators in the WHERE clause

The following operators can be used in the WHERE clause:

operator Description
= Equals
<> Not equal to. Note: in some versions of SQL, this operator can be written in! =
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
Between Within a range
Like Search for a pattern
Inch Specify multiple possible values for a column
Sqland & OR operators

The and & OR operators are used to filter records based on more than one condition.

If both the first condition and the second condition are true, the AND operator displays a record.

If only one of the first and second conditions is true, the OR operator displays a record.

SqlORDER by keyword

The ORDER BY keyword is used to sort the result set.

The ORDER BY keyword is used to sort the result set by one column or multiple columns.

The order by keyword sorts records by default in ascending order. If you need to sort records in descending order, you can use the DESC keyword.

SqlINSERT into statementThe INSERT INTO statement is used to insert a new record into the table. SQL INSERT into syntax

The INSERT into statement can be written in two ways.

The first form does not need to specify the column name to insert the data, just provide the inserted value: The second form needs to specify the column name and the value to be inserted:

Did you notice that we didn't insert any numbers into the ID field?
The ID column is automatically updated, and each record in the table has a unique number.

SQL Learning 1 Beginner (RPM)

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.