MySQL基本简单操作
时间:2014-12-11 00:53 来源:linux.it.net.cn 作者:IT
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)
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) |