3 MySQL SQL Basics

Source: Internet
Author: User

Directory

1. SQL Overview
2. Database operations
3. Table Operations
4. Record operations

1. SQL Overview

SQL, Structured Query Language (structured Query Language), a database query and programming language for accessing data and querying, updating, and managing relational database systems. Case insensitive.

It consists of 6 main parts:
1. Data definition Language (DDL): common reserved words create and drop.
2. Data Query Language (DQL): SELECT, ORDER by.
3. Data manipulation Language (DML): Insert,update and delete.
4. Data Control Language (DCL): Grant,revoke.
5. Transaction processing Language (TPL): BEGIN transaction,commit and rollback.
6. Pointer Control Language (CCL): DECLARE cursor,fetch into.

SQL main operation: increase, delete, change, check.
SQL Primary Action object: Database, table, record.
(Note: The following lab operations are only getting started practiced hand, SQL is far more powerful than these!) )

2. Database operations

2.1 Create a database. Enter MySQL via phpMyAdmin, click on the SQL button in the left column, for example.

In the pop-up box, enter:CREATE database schooldb; Click Execute.

2.2 Querying the database
  show databases;

  
2.3 Deleting a database
  Drop database schooldb;

  

show databases;

  


3. Table Operations
3.1 Creating a Table
  Create Database schooldb;
Select Schooldb in the left column, and click the SQL button in the right navigation bar , such as. The following actions in the database allow you to open the SQL edit box with this button.

  
  CREATE TABLE Student (
ID Int (5) is not NULL,
Name varchar (20),
Birthday Date
);

3.2 Enquiry Form
  Show tables;
DESC student;

3.3 Change Table
Add column
Delete Column alter table student drop column phone;

3.4 Delete table
drop table student;

4. Record operations
4.1 Creating a Table
  CREATE TABLE Student (
ID Int (5) is not NULL,
Name varchar (20),
Birthday Date
);
Inserting records
  INSERT into student values (1, ' Guo Jing ', ' 1990-01-01 ');
INSERT into student values (2, ' Huang Rong ', ' 1992-02-02 ');
INSERT into student values (3, ' Ling Hu ', ' 1993-03-03 ');
INSERT into student values (4, ' Dong Fang ', ' 1994-04-04 ');

4.2 Querying records
  SELECT * from student;

  

4.3 Change record
  Update student set birthday= ' 1993-04-04 ' where Name= ' Dong Fang ';

4.4 Deleting records
  Delete from student where Name= ' Dong Fang ';

3 MySQL SQL Basics

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.