> 数据库 > MySQL >

MySQL基本简单操作

MySQL基本简单操作
 
 
itnetcn@SL400:~$ mysql -u root -p  #登录数据库
 
mysql> CREATE DATABASE ApingDB; #创建数据库
 
mysql> show databases;  #查看数据库
+--------------------+
| Database           |
+--------------------+
| ApingDB            |
+--------------------+
 
mysql> use itnetcnDB;     #选中数据库
 
mysql> CREATE TABLE Nikon (time DATE,PriceA INT,PriceB INT);  #创建表与字段
 
mysql> INSERT INTO Nikon values("2013-10-10","3199","3988");  #增加数据
mysql> INSERT INTO Nikon values("2013-10-09","3199","3988");  #增加数据
 
mysql> SELECT * FROM Nikon;   #查询表中数据
+------------+--------+--------+
| time       | PriceA | PriceB |
+------------+--------+--------+
| 2013-10-10 |   3199 |   3988 |
| 2013-10-09 |   3199 |   3988 |
+------------+--------+--------+
 
mysql> UPDATE Nikon set PriceB="4000" where time="2013-10-10";  #更改数据(将2013-1010的PriceB数据更改4000)
 
mysql> DELETE FROM Nikon WHERE time="2013-10-10";  #删除数据 (删除2013-10-10的一条数据)
 


(责任编辑:IT)