-
-
Save MangoLiu/8893785 to your computer and use it in GitHub Desktop.
常用数据库命令
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1:使用SHOW语句找出在服务器上当前存在什么数据库: | |
mysql> SHOW DATABASES; | |
2:创建一个数据库MYSQLDATA | |
mysql> CREATE DATABASE MYSQLDATA; | |
3:选择你所创建的数据库 | |
mysql> USE MYSQLDATA; (按回车键出现Database changed 时说明操作成功!) | |
4:查看现在的数据库中存在什么表 | |
mysql> SHOW TABLES; | |
5:创建一个数据库表 | |
mysql> CREATE TABLE MYTABLE (name VARCHAR(20), sex CHAR(1)); | |
6:显示表的结构: | |
mysql> DESCRIBE MYTABLE; | |
7:往表中加入记录 | |
mysql> insert into MYTABLE values (”hyq”,”M”); | |
8:用文本方式将数据装入数据库表中(例如D:/mysql.txt) | |
mysql> LOAD DATA LOCAL INFILE “D:/mysql.txt” INTO TABLE MYTABLE; | |
9:导入.sql文件命令(例如D:/mysql.sql) | |
mysql>use database; | |
mysql>source d:/mysql.sql; | |
10:删除表 | |
mysql>drop TABLE MYTABLE; | |
11:清空表 | |
mysql>delete from MYTABLE; | |
12:更新表中数据 | |
mysql>update MYTABLE set sex=”f” where name=’hyq’; | |
13 查询表中所有的数据 | |
mysql>select * from student | |
14 删除数据库 | |
mysql>drop database dbname; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment