Python Learning (16)--Database

Source: Internet
Author: User

I. Introduction of the Database

A database (DATABASE,DB) organizes, stores, and manages data in accordance with a structure, and is a repository built on a computer's storage device.

A database is a collection of data that is stored in a certain way, shared for multiple users, with the smallest possible redundancy, and independent of the application. In simple terms, it can be regarded as electronic file cabinet-the place where electronic files are stored, and users can operate new, intercepted, updated and deleted data in the file.

Second, the database system

The database system has 3 main components: Database, database management system, database application

Database System: A warehouse for storing data

Database Management system: Software for user-managed databases

Database application: A software supplement to the management database used to improve the processing power of the database system

Third, the SQL language

SQL (Structured query Language) is a structured query language, and the database management system specifically manages the data in the database through the SQL language and communicates with the database.

Benefits of SQL:

1.SQL is not a proprietary language for a particular database vendor. Almost all important DBMS support SQL, so learning this language enables you to work with almost any database.

2.SQL is easy to learn, its statements are all composed of highly descriptive English words, and the number of these words is not many.

3.SQL Although seemingly simple, it is actually a powerful language, with the flexibility to use its language elements for very complex and advanced database operations.

SQL provides the capabilities of the database management system:

SQL language is a database query and programming language, which is mainly used for accessing data, querying data, updating data and Managing database system, SQL is divided into 4 parts.

Data definition Language (LANGUAGE,DDL): DROP, CREATE, Alter, and so on; Database definition language. Primarily used to define databases, tables, views, indexes, triggers, and so on. The CREATE statement is used primarily for creating databases, creating tables, and creating views. The ALTER statement is primarily used to modify a table

Definition, modify the definition of the view. Drop statements are primarily used to delete a database, delete a table, delete a view, and so on.

Data manipulation Language,dml: INSERT, UPDATE, DELETE statement, database operation language. Mainly used to insert data, update data, delete data. The INSERT statement is used to insert data, and the UPDATE statement is used to update the data, and the DELETE statement deletes the data.

Data Query Language (LANGUAGE,DQL): SELECT statement. Used primarily for querying data.

Data Control Language (Language, DCL) statement: Database Control language. Primarily used to control the user's access rights. Where the grant statement is used to add permissions to the user, the REVOKE statement is used to reclaim the user's permissions.

Iv. Classification of databases

A relational database (relational) is a database created on a relational model that uses mathematical concepts and methods such as set algebra to process data in a database.

Mysql,sol Server,oracle,db2,sybase

RDBMS: The features of the relational database management system (relational Management Systems):

1. The data appears in tabular form
2. Various record names for each behavior
3. Data fields corresponding to record names for each column
4. A number of rows and columns form a single sheet
5. A number of forms form database

Non-relational database (NOSQLL): MongoDB, Redis

V. Operation of the database

Display database: show databases;

Enter the specified database: use database name;

Show all tables for the current database: show tables;

Creating database: Create database name default character Set=utf8;

Remove database: drop database name;

  

Vi. operation of database tables

1. Creating Table: Create table table name (

ID varchar (5) NOT null primary key,

Name varchar (10),

Age int

);

2. Delete tables: drop table name;

3. Add Table data: I

#一次增加一条数据

Insert into Studentinfo (name,sex,age) VALUES (' abc ', ' Male ', ' 18 ');

#一次增加多条数据

Insert into Studentinfo (name,sex,age) VALUES (' abc ', ' Male ', ' + '), (' qwe ', ' female ', ' 19 ');

4. Modify data: Update studentinfo set name= ' abc ' WHERE name= ' abc ';

5. Delete data: Delete from table name where condition;

  

          

Python Learning (16)--Database

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.