Database Learning Notes

Source: Internet
Author: User
Tags ibm db2 access database

Definition of L:

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

    • SQL refers to the Structured Query language, the full name is 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.

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

3.SQL syntax

    • Use database name; command to select a database.
    • set names UTF8; The command is used to set the character set used.
    • SELECT * from Websites; Read the data table information.
    • SQL is not case sensitive: Select is the same as select.
    • SELECT statement
SELECT name,country from Websites;
SELECT DISTINCT country from Websites; // the SELECT DISTINCT statement is used to return only different values. 
SELECT * from Websites WHERE country='CN';
    • and & OR Operators
SELECT * from websiteswhere country='CN';
SELECT * from websiteswhere country='USA'OR Country=' CN ';
    • ORDER BY syntax
SELECT * from websitesorder by Alexa; // the default is in ascending order, that is, select * from Websites order by Alexa ASC
SELECT * from websitesorder by Alexa DESC;
    • INSERT INTO syntax

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

INSERT into Table_namevalues (Value1,value2,value3,...);

The second form requires specifying the column name and the value to be inserted:

INSERT into table_name (COLUMN1,COLUMN2,COLUMN3,...) VALUES (Value1,value2,value3,...);
    • Update syntax
UPDATE Websites SET alexa='country= ', 'USA'  WHERE name=' Rookie tutorial ';

Take extra care when updating records! In the above example, if we omit the WHERE clause, all Alexa and country in the data will be changed

    • Delete syntax
DELETE from websiteswhere name=' Baidu ' and country='CN  ';
    • Select top, limit, rownum syntax

Not all database systems support the SELECT top syntax, the following is the Sql,ms Access database system

 PERCENT * from Websites;

MY SQL Database System

SELECT column_name (s) from table_namelimit number;

Oracle Database System

SELECT *<=5;

Like operator

SELECT *'g%' *'%oo%';
wildcard characters Description
% Override one or more characters
_ Replaces only one character
[Charlist] Any single character of the word columns

[^charlist]

Or

[!charlist]

Not any single columns of the word

Database Learning Notes

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.