对于MySql已经是第二次看了,这次主要的目的是将MySql系统的归纳一边,之前学MySql是将笔记写在本子上,以后不想总带着本子,所以再花点时间把笔记归纳在博客中。下午已将安装步骤详细的写了,现在归纳他的基本语法。至于语法很多都是满足Sql语法的,和Sql Server 、Oracle都差不多。符合“>”后的都是在dos中验证过的,并且复制后直接可以运行。
1.连接数据库:
>#在mysql中‘#’是注释符号,连接数据库时,输入账号和密码
>mysql -u root -p wwh
2.显示所有的数据库
>show databases;
3.切换,显示某个数据库
>use test;
4.显示对应数据库中的所有表:
>show tables;
5.创建一个名称为user的数据库
>create database user;
6.创建一个使用utf8字符集的user数据库
>create database if not exists user character set UTF8;
>#如果不存在user,就创建,如果存在,则不创建user数据库
7.创建一个使用utf8字符集,并带校对规则的user数据库
>create database if not exists user character set UTF8 collate utf8_general_ci;
8.查看前面创建的user数据库的定义信息
>show create database user;
9.删除前面创建的user数据库
>drop database if exists user;
10.查看服务器中的数据库,并把其中user库的字符集修改为gbk
>alter database user character set gbk;
11.修改、备份、恢复数据库数据(这应该算是MySql中特有的吧,不同的数据库备份恢复的指令不一样)
备份:
c:\> mysqldump -u root -p wwh > d:\user.sql 回车(可以无分号结束)
密码回车
注意:该SQL命令是MySQL特有的,必须是MySQL环境外执行,即Window中dos界面环境中执行,并未进入到MySql的服务器中。
恢复:
mysql:\> source d:\mydb2.sql;回车(需要分号结束)
注意:该SQL命令是MySQL特有的,必须是MySQL环境中执行。
12. MySQL支持数据类型
注意:
(1)Date/Datetime/TimeStamp,定界符使用''或""(单引号和双引号),但部份数据库可能不支持"",优先推荐''作为定界符,对于日期类型, MySQL数据库有一个的判段-功能
(2)varchar(变长)/char(定长)
(3)Text(大于65536字符的数据)/Blob(存储二进制多媒体数据,例如Mp3等),该二类型都有四个子类型,根据存储内容的大小进行选择
(4)INT型有带符号和无符号之分,int(5)表示int默认为5位,如果插入id值,小于5位,左补空格,如果插入id值,大于5位,按照插入值,但必须满足int类型的大小确定
(5)FLOAT(M,D),D表示小数点后的D位,按四舍五入计算,M表示除小数点外的所有位数总和
(6)tinyint/smallint/mediumint/int/bigint-->1B/2B/3B/4B/8B
13.优化的方法:
以时间换空间或者以空间换时间。
14.注意:
在实际的开发中,可以考虑吧频繁用到的信息,优先考虑效率,存储到一张表中,把不常用的信息和比较占空间的信息,有限考虑空间占用,存储到辅表中。例如:QQ空间中的用户名和密码,还有日志和留言板的信息存储。

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment