MySQL simple command example

Source: Internet
Author: User
C: \ mysql \ bin > MySQL - U Root - P
Enter password: ****
Welcome To The MySQL monitor. Commands End With ; Or \ G.
Your MySQL connection ID Is 4
Server version: 5.0 . 51B - Community - NT MySQL Community edition (GPL)

Type'Help;' Or '\ H' ForHelp. Type'\ C' ToClear the buffer.

MySQL > Show databases;
+ -- ------------------ +
| Database |
+ -- ------------------ +
| Information_schema |
| MySQL |
| Mytest |
| Tjtz |
| Tjtz_148280117 |
+ -- ------------------ +
5 Rows In Set ( 0.00 Sec)

MySQL> Create DatabaseMytest2;
Query OK,1Row affected (0.01Sec)

MySQL > Show databases;
+ -- ------------------ +
| Database |
+ -- ------------------ +
| Information_schema |
| MySQL |
| Mytest |
| Mytest2 |
| Tjtz |
| Tjtz_148280117|
+ -- ------------------ +
6 Rows In Set ( 0.00 Sec)

MySQL > Use Mytest2;
Database Changed
MySQL> Create Table Testtable (
-> ID Int ( 4 ) Auto_increment Not Null Primary Key ,
-> NameChar ( 10 ) Not Null ,
-> Address Char ( 50 ) Default ' Jinan ' ,
-> Year Date );
Query OK, 0 Rows affected ( 0.09 Sec)

MySQL > Show tables;
+ -- ----------------- +
| Tables_in_mytest2 |
+ -- ----------------- +
| Testtable |
+ -- ----------------- +
1 Row In Set ( 0.05 Sec)

MySQL> Insert IntoTesttableValues('','Zhangsan','','2011-12-29');
Query OK,1Row affected,1Warning (0.00Sec)

MySQL > Select * From Testtable;
+ -- -- + ---------- + --------- + ------------ +
| ID | Name | Address | Year |
+ -- -- + ---------- + --------- + ------------ +
| 1 | Zhangsan | | 2011 - 12 - 29 |
+ -- -- + ---------- + --------- + ------------ +
1 Row In Set ( 0.00 Sec)

MySQL> UpdateTesttableSetAddress='Jiefang Road';
Query OK,1Row affected (0.06Sec)
Rows matched:1Changed:1Warnings:0

MySQL > Select * From Testtable;
+ -- -- + ---------- + -------------- + ------------ +
| ID | Name | Address | Year |
+ -- -- + ---------- + -------------- + ------------ +
| 1 | Zhangsan | Jiefang Road | 2011 - 12 - 29 |
+ -- -- + ---------- + -------------- + ------------ +
1 Row In Set ( 0.00 Sec)

MySQL> Insert IntoTesttableValues('','Lisi',Null,'2012-1-3');
Query OK,1Row affected,1Warning (0.00Sec)

MySQL > Select * From Testtable;
+ -- -- + ---------- + -------------- + ------------ +
| ID | Name | Address | Year |
+ -- -- + ---------- + -------------- + ------------ +
| 1 | Zhangsan | Jiefang Road | 2011 - 12 - 29 |
| 2 | Lisi | Null | 2012 - 01 - 03 |
+ -- -- + ---------- + -------------- + ------------ +
2 Rows In Set ( 0.00 Sec)

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.