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

创建数据库:
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;
学透前端行业所有技术,玩遍北京周边所有城市。然后我会回到那个生我养我的地方,因为有亲人的地方才是家。
原文地址:https://www.cnblogs.com/snowinmay/p/3166809.html