您的位置:首页 > 数据库

数据库操作相关(sql语句-命令行)

2013-07-02 13:43 495 查看
创建数据库:
create database books;
创建用户:
mysql> grant select,insert,delete,uptate

-> on books.*

-> to dada identified by 'yujianqi2011';

使用数据库:

use dbname;
use dada;

新建数据库表
create table tablename(columns);
create table demo(
userid int unsigned not null auto_increment primary key,
username char(50) not null,
password char(20) not null,
age int not null,
city char(20) not null
);

显示数据库表
show tables;

在数据库中插入数据
insert into demo values(NULL,"dada","yujianqi2011",27,"beijing");
insert into demo values(NULL,"xiaoyin","yujianqi2011",26,"shanghai");

查询数据
select name, city from customers where name="dada";

更新数据
update customers
set address = "北京市海淀区";

删除数据
delete from dada where name = "dada";

表的删除
DROP TABLE table;

数据删除
DROP DATABASE database;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: