Example of self-learning SQL language (implemented using MySQL)

Source: Internet
Author: User

SQL language as a database management standard language has a very wide range of application scenarios, beginners to choose the database software is a lightweight free (this extremely important) MySQL, download links are as follows: http://www.mysql.com/downloads/, The author's program in the MySQL Visual Interface Workbench script file and execution, which is more convenient and intuitive than in command-line mode of execution. Amway a MySQL Rookie of the book Planners and CNECC "mysql5.5--from the beginning of learning" This book (resource self-seeking, in order to avoid infringement here does not give links to, of course, also welcome to buy this paper book support author).

Example: Demonstrates the role of some SQL statements

Test1.sql file:

/*Date:2016/2/14description:sql Learning-1writer:wayne*/CREATE DATABASEgame_db; #创建一个数据库 Usegame_db; #指定当前使用数据库CREATE TABLEgame #创建数据表 (IDINT PRIMARY KEYauto_increment, Job_nameVARCHAR( -), weaponsVARCHAR( -), SkillsVARCHAR( -), Hero_typeVARCHAR( -) ); #往数据表中添加数据INSERT  intoGameVALUES(1,'Heroes','swords, axes, blunt instruments','Ultimate Strike','Warrior'),                       (2,'Saint Knight','swords, Blunt instruments','Sacred Shock','Warrior'),                       (3,'Black Knight','Lance, Spear','Dark Piercing','Warrior'),                       (4,'Bishop','long sticks, short battles','Holy Light Shines','Magician'),                       (5,'Fire Poison Mage','long sticks, short battles','Doomsday Flames','Magician'),                       (6,'Master of Ice Thunder','long sticks, short battles','Ice Roaring','Magician'),                       (7,'God shooter','Bows','Storm Arrow Rain','Archer'),                       (8,'Arrow God','Crossbow','Ultimate Shooting','Archer'),                       (9,'Grand Theft','Dagger and Dagger','assassination','Ranger'),                       (Ten,'Hermit','Gloves','Four even darts','Ranger'),                       ( One,'Shadow double Knife','Dagger and Dagger','Ultimate Chop','Ranger');SELECT *  fromgame; #查询指定表中全部数据CREATE OR REPLACE VIEWWarrior_view as SELECT *  fromGameWHEREHero_type='Warrior'; #建立视图SELECT * fromWarrior_view; #查询视图中数据SELECT COUNT(*) fromgame; #统计视图中数据SELECTHero_type asHero,COUNT(*) asNum fromGameGROUP  byHero_type; #按指定段名分组查询数据DROP TABLEgame; #删除指定表DROP DATABASEgame_db; #删除指定数据库

Display effect, the results of different select operations are displayed sequentially (under Workbench):

Revised on 2016/2/14 by Mustang fungus

Spit a slot: Today is Valentine's Day, I am waiting for you, where are you O (╯-╰) O?

Example of self-learning SQL language (implemented using MySQL)

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.