1.查看數據庫
MySQL> show databases;
2.選擇數據庫
MySQL> use phpddt.com;
3.置字符集
MySQL> set names 'gbk';
4.查詢數據庫中的表
MySQL> show tables;
5.MySQL基本操作創建表
MySQL> create table phpddt(
-> tid int(10) not null,
-> tname varchar(100) not null,
-> tdate datetime not null default '0000-00-00',
-> primary key (tid));
6.查看表結構
MySQL> desc phpddt_users;
7.添加列
MySQL> alter table phpddt add(tage int(3));
8.修改原表結構
MySQL> alter table phpddt modify tage int(5) not null;
9.修改列的默認值
MySQL> alter table test alter tage set default '0';
10.去掉列的默認值
MySQL> alter table phpddt alter tage drop default;
11.刪除列
MySQL> alter table phpddt drop column tage;
12.插入數據
MySQL> insert into users(tid,tname,tdate) value(1,'yangjuqi','2008-03-21');
13.查詢數據
MySQL> select * from users;
14.模糊查詢
MySQL> select * from users where tname like '%丁%';
15.修改數據
MySQL> update users set tname='李四' where tid='2';
16.MySQL基本操作刪除數據
MySQL> delete from users where tid='2';
17.刪除表
MySQL> drop table users ;
18.重命名表
MySQL> alter table test rename testbak;
19.分頁查詢(limit 起始行,取多少行)
MySQL> select * from testbak limit 2,1;
20.刷新數據庫
MySQL> flush privileges;
21.顯示數據庫版本
MySQL> select version();
22.顯示當前時間
MySQL> select current_date;
23.修改用戶密碼
D:\php\MySQL\bin>MySQLadmin -uroot -proot password yangjuqi
24.將查詢出的數據寫入文件
MySQL> select * from testbak into outfile "d:/test.txt" fields terminated by ",";
25.查看數據庫狀態
MySQL> status;
26.MySQL基本操作查看所有編碼
MySQL> show variables like 'character_set_%';
27.導入sql文件命令
MySQL>source d:/MySQL.sql;