Orecle Mysql Basic SQL Statement DDL & DML Introduction and summary by ICE Glass

Source: Internet
Author: User

first of all, to popularize the simple way to install MySQL:yum


Yum Search MySQL (find out what's on MySQL)

3 items to install after finding

    1. Mysql.i386

    2. Mysql-server.i386

    3. Mysql-devel.i386


Service mysqld start after installation (start MySQL service)


Go to MySQL

Mysql-h-U root-p

Password directly enter the beginning of the password is silent, you can change the password in MySQL or create an account and other operations



MySQL's SQL statement is broadly divided into 4 types


DDL (definition Statement)


Create

Create DATABSE (Establishment database)

Example: Create Database Jasondb (creates a database called jasondb)

* The created database must be selected to create a new form inside

-Use a space + database name in the way.

Example: Use Jasondb

View existing database syntax is show databases;


CREATE table (Column Name fields as field properties);

Example: CREATE TABLE Jason (column Name field); (Creating a table named Jason Plus content)



Drop

Drop database name (deleted databases)

Example: Drop database jasondb;

drop table name (delete table name)

Example: Drop table Jason;




Alter

ALTER TABLE table name


1. Alter....add

-ALTER TABLE name add new Column Name field Type Fields property

Example: Alter TABLE Jason add stuid (new list) int (field type) NOT NULL default (field property);

* Field Name field type and field properties must not be converted sequentially in order.


2. Alter....drop

2.1-alter table name drop column name;

Example: ALTER TABLE Jason drop STUID;


2.2-alter table Name drop index column name; (delete unique)

Example: ALTER TABLE Jason DROP INDEX stuid;


2.3-alter table Name drop PRIMARY KEY (primary key list name); (Delete primary key)

Example: ALTER TABLE Jason drop PRIMARY key stuid;

3. alter....modify(change all attribute types except list name)

Example: ALTER TABLE Jason Modify column name type attribute;

4. Alter....change(can change all existing lists)

Example: ALTER TABLE JAson change old column name new column name type attribute;





DML (Management statement)



Update

Update: Set: where


Update table name set field name = new value where condition;

Example: Update jaosn set stuid=1 WHERE condition = content;

Update table name set field name = new value order By field limit number of rows (updated sequentially qualified rows)

Example: Update Jason set stuid=1 ORDER by Stuid limit 5;




Delete

Delete: From.. where

Delete from table name where condition;

Example: Delete from Jason where stuid=1;


Delete from table name order BY field limit line number;

Example: Delete from Jason order by Stuid limit 5;


Insert

Insert INTO ... () values ();

Insert into table name (option) VALUES (' ', ' ', ' ', ');


This article from "11094147" blog, declined reprint!

Orecle Mysql Basic SQL Statement DDL & DML Introduction and summary by ICE Glass

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.