共计 910 个字符,预计需要花费 3 分钟才能阅读完成。
1. 创建数据库
create database ssm; //mysql
use analysis //mongodb
2. 切换数据库
use ssm; //mysql
use analysis //mongodb
3. 删除数据库
drop database ssm; //mysql
db.dropDatabase() //mongodb
4. 数据定义与数据操纵
//mysql
create table `teacher`(
`id` int,
`name` varchar(20),
`salary` decimal(7,2),
`birthday` date,
`timestamp` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
primary key (`id`)
);
alter table `teacher` drop `birthday`;
alter table `teacher` add `birthday` date;
drop table `teacher`;
insert into `teacher` (`id`,`name`,`salary`,`birthday`) values (1,"大明",50000.00,"1997-01-01");
update `teacher` set `salary`=5000 where `name`="大明";
delete from `teacher` where `name`="大明";
//mongo
db.createCollection("student")
db.student.drop()
db.student.insert({
name: '小明',
birthday:"2007-01-01",
scholarship: true,
success:{"math":80,"data analysis":90},
tags: ['男', '2016 级', '清华'],
timestamp:parseInt(new Date().getTime()/1000)})
db.student.update({name:'小明'},{$set:{name:'小元'}})
db.student.remove({name:'小元'})
正文完