SQL basics (1), SQL BASICS (

Source: Internet
Author: User

SQL basics (1), SQL BASICS (

I. mysql management commands

/Applications/XAMPP/xamppfiles/bin/mysql-uroot

1. display all databases

Show databases;

2. Enter the mysql database

USE mysql;

3. display the currently displayed Library

Select database ();

4. display the names of all tables in the current database

Show tables;

5. query all records of the SQL table name

SELECT * FROM SQL;

6. log out of the mysql server

Exit;

# Query the current MySQL Encoding

# Method of importing SQL files source d:/xx. SQL

 

II,

SQL statement category
1: DDL Data Define Language
Define database features and table structure-operation Columns


CREATE/DROP/ALTER/TRUNCATE

Create database crm;

Create database crm1 character set UTF8;

Create table student (

Id int primary key AUTO_INCREMENT,

Name VARCHAR (25 ),

Score DOUBLE (10, 2 ),

Birthday DATE

);

Drop database crm1;

Drop database student;

Alter table student ADD sex VARCHAR;

Alter table student DROP birthday;

Alter table student MODIFY score INT;

 

2: DML Data Manipulate Language
Operation Table Record row-operation row
INSERT/DELETE/UPDATE

 

Insert into student VALUES (null, 'cluster', 99, '2017-8-14 ');

Insert into student (partial column name) VALUES (...);

Delete from student WHERE score = 99;

UPDATE student SET score = score/2 WHERE name = 'cluster ';


3: DQL Data Query Language ***
SELECT

 

 

SELECT * FROM student order by score; // ascending

SELECT * FROM student order by score DESC; // descending ORDER


4: DCL Data Control Language
Control Database User Permissions
GRANT/REVOKE

Iii. SQL Functions

MAX ();

MIN ();

AVG ();

COUNT ();

SUM ();

 

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.