1. 登陆 : mysql -uroot -proot
2. 查看数据库: show database;
3. 查看表: show tables;
4. 当前选择的库状态:SELECT DATABASE();
5. 显示数据表字段:describe 表名;
6. 数据库操作
添加:INSERT INTO [表名] VALUES('','',......顺序排列的数据); 或者 insert into links(name,address) values('jerichen','gdsz');
插入多条 : insert links (name,url) values('jerichen','gdsz'),('alone','gdgz');
查询: SELECT * FROM [表名] WHERE ([条件]);
建立索引:CREATE INDEX [索引文件名] ON [表名] ([字段名]);
删除:DELETE FROM [表名] WHERE ([条件]);
修改:UPDATE [表名] SET [修改内容如name = 'Mary'] WHERE [条件];
新建表:
DROP TABLE IF EXISTS `app` ; CREATE TABLE IF NOT EXISTS `app` ( `app_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NOT NULL, `description` VARCHAR(255) NULL, `app_key` CHAR(8) NOT NULL, `app_secret` CHAR(32) NOT NULL, `is_active` TINYINT(1) NOT NULL DEFAULT 1, `created` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `updated` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`app_id`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_general_ci;