时间:2021-07-01 10:21:17 帮助过:7人阅读
show databases;
use 数据库名;
show tables;
describe 表名;
SELECT * FROM 表名
create databse 库名;
create table 表名 (字段设定列表); mysql> create table name( -> id int auto_increment not null primary key , -> uname char(8), -> gender char(2), -> birthday date ); Query OK, 0 rows affected (0.03 sec) mysql> show tables; +------------------+ | Tables_in_userdb | +------------------+ | name | +------------------+ 1 row in set (0.00 sec) mysql> describe name; +----------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+---------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | uname | char(8) | YES | | NULL | | | gender | char(2) | YES | | NULL | | | birthday | date | YES | | NULL | | +----------+---------+------+-----+---------+----------------+ 4 rows in set (0.00 sec) 注: auto_increment 自增 primary key 主键
insert into name(uname,gender,birthday) values(‘张三‘,‘男‘,‘1971-10-01‘);
update name set birthday=‘1971-01-10‘ where uname=‘张三‘;
delete from name where uname=‘张三‘;
drop table 表名
drop database 库名;
mysqldump -u root -p --opt 数据库名>备份名; //进入到库目录
mysql -u root -p 数据库名<备份名; //恢复时数据库必须存在,可以为空数据库
原文: http://www.cnblogs.com/xdpxyxy/archive/2012/11/16/2773662.html
Linux下mysql的常用操作
标签:tables style http dump describe str databases arch int