Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic operation commands and SQL statements of Mysql database

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The knowledge points of this article include: an overview of Mysql database, basic operation commands of Mysql database and SQL statements of Mysql database. After reading the complete article, I believe you have a certain understanding of the use of Mysql database.

First, an overview of the database role of the database: data persistence preservation, high reliability, high availability, rapid data extraction. Database storage type: relational database non-relational database. 1.1. The storage structure of relational database is a two-dimensional table, and the data that reflects things and their relationships is saved in the form of a table. in each two-dimensional table, each row is called a record, which is used to describe the information of an object, and each column is called a field. Used to describe an attribute of an object.

Relational database: MySQL (oracle), sql server (Microsoft), access (Microsoft), oracle,db2 (IBM), sybase (sybase) 1.2, non-relational database non-relational database storage mode key-value mode (key-value), key-based storage, delete, modify data column storage (Column-oriented), the way to store related data in Chinese files The database consists of a series of data items Each data item has a name and corresponding value non-relational database (collectively referred to as NOSQL): redis (memory database / cache database): Kmuri V value to key-value variable name-value memcache (memory database / cache database): the advantages of KMel V value for non-relational database: the need for high concurrent reading and writing of database for efficient storage of massive data and high scalability and high availability for accessing database II. Database basic operation command 2.1.View database structure 1, view database list information show databses

2. View the data table information in the database use database name; # # switch to the library show tables; # # View the data table in the database

3. Display the structure of the data table describe [database name]. Table name

Display the structure of the data table (field) 3. SQL statement 3.1, SQL language category 1, SQL language is the abbreviation of Structured Query Language That is, structured query language is the standard language for maintaining and managing relational databases, such as data query, data update, access control, object management and other functions 2. SQL classification DDL: data definition language DML: data manipulation language DQL: data query language DCL: data control language 3.2, DDL statement DDL statement is used to create database objects Such as libraries, tables, indexes, etc. 1. Use DDL statements to create new libraries, tables to create databases, create database custom database names

Create a datasheet:

Use school;Database changed / / create no problem show tables;Empty set (0.00 sec) / / No data sheet # # create table: contains [id (student number) name (name) address (address) score (grade)] create table info (id int (4) not null, name char (10) not null, address varchar (50) default 'Nanjing', score decimal, primary key (id))

2. Delete the database using the DDL statement and delete the entire data table: drop table data table name; drop table info;## delete the database: drop database database name; drop database school

3.3.The DML statement DML statement is used to manage the data in the table, including the following operations: INSERT: insert new data UPDATE: update existing data DELETE: delete unwanted data 1, insert new data record INSERT INTO table name (field 1, field 2, … ) VALUES (value of field 1, value of field 2, … ) INSERT INTO table name VALUES (the value of field 1, the value of field 2, … ) # # the values inserted into the fields in the info data table should correspond to the order of the fields in the table. Do not inadvertently write mysql > insert into info (id,name,address,score) values. (1) mysql > insert into info (id,name,address,score) values (2)

2. Modify the data record in the data table # # modify the data table: the row corresponding to the set field where of the update data table name; update info set address=' Shanghai 'where id=3

Expression.

Update stu set address=' Hangzhou 'where id=4

one

3. Delete the specified data record in the data table # # delete the data in the data table: delete from data table name data table field; # # delete the data delete from info where name='wangwu' named wangwu in the info data table

3.4.The DQL statement DQL is a data query statement with only one item: SELECT is used to find qualified data records from a data table without specifying the condition # # query data table all information select * from info

# # specify conditional select field name 1 and field name 2 when querying. From table name where conditional expression select * from info where id=2

After reading the above, do you have any further understanding of the use of Mysql database? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report