MySQL database programming--Development Introduction/SQL statement

Source: Internet
Author: User
Tags mysql client php class

I. MySQL installation and managementThe tar unpacking command
Tar xvf package file name
Tar-packed commands
tar cvf file names to package
rpm Unload Command
RPM-E Package Name
RPM-E Package name--nodeps forcibly unloaded, does not check package dependencies
RPM installation Package Command
RPM-IVH Package Name

two. Character Set
1, the first operating system's character set is UTF8
View operating system character Set commands
locale
2. When creating the database, use character set UTF8; Specify the character set as UTF8

3. Setting the MySQL client character set

SET NAMES UTF8;
4, CRT set to UTF8

three.SQL language
in SQL language, strings are quoted in single quotes.
search for students older than 21 years old
SELECT * FROM table1 WHERE age >;
Query C + + class all students
SELECT * FROM table1 WHERE class = ' C + + class ';
Query C + + class all students and older than
SELECT * FROM table1 WHERE class = ' C + + class ' and ' Age > ';

Find all the students surnamed Wang
SELECT * FROM table1 WHERE name is like ' Wang% ';

Add PATH environment variable in Windows
C:\mysql\lib; C:\mysql\bin
MySQL port number 3306, to join 3306 ports in Linux to the list of trusted ports in the firewall
distinct represents filtering for duplicate values

aggregation functions are often used in conjunction with group by words.

find the oldest student's name in the old teacher's class
Select A.name from table1 A, table3 b where A.class = B.class and B.teacher = ' Ms. Cang '
and a.age = (select Max (c.age) from table1 C, table3 d where c.class = D.class and D.teacher = ' Cang
teacher ');
in the SELECT statement, which field is used in the Where query, the field must be indexed

queries for unique indexes are more efficient than normal indexes
the primary KEY (ID) statement is equivalent to establishing a unique index for the ID field when the table is established

four. Operational Database
Login
mysql-u root-p
how to log in to remote MySQL server
mysql-h IP address-u user name-P
Working with Databases
Use db1;
Set character sets
set names UTF8;
View Table Structure
desc table1;
Insert Data:
INSERT into table1 (name, sex, Age, Class) VALUES (' Zhang San ', ' Male ', 24, ' 0802 classes ');
Query data:
SELECT * FROM table1;
Execute SQL Script
Source My.sql--my.sql-------------------
Insert INTO table1 (name, sex, Age, Class) VALUES (' Xiao Wang ', ' Female ', ' C + + class '); insert into table1 (name, sex, Age, Class) VALUE S (' Xiao Li ', ' Male ', ' C + + class '), insert into table1 (name, sex, Age, Class) VALUES (' Xiao Zhang ', ' Male ', ', ' Java class '); insert into table1 (n Ame, sex, age, Class) VALUES (' pock ', ' female ', ' C + + class '), INSERT into table1 (name, sex, age, Class) values (' Zhang's grandfather ', ' Male ', 24, ' PHP class '); INSERT into table1 (name, sex, Age, Class) VALUES (' Little Dragon Girl ', ' female ', ', ' C + + class ');


C + + Institute (+) MySQL database programming--Introduction to development/sql statements

Related Article

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.