mysql基本语句
mysql -u root -p;
登录数据库
show databases;
展示数据库
show tables;
展示表
desc messages;
查看messages表的结构
drop database lovestory;
删除lovestory数据库
create table messages (
id int primary key auto_increment,
name varchar(50),
article text,
created_at timestamp
)engine=InnoDB default charset=utf8;
建立messages表
(InnoDB类型支持事务。mysql默认采用MyISAM引擎,该类型表不支持事务,仅存储数据,优点在于读写很快。)
alter table photo rename photos;
修改表名
alter table messages modify article text;
修改字段数据类型
(article:字段名,text:要修改成的类型)
alter table messages change article myarticle varchar(1000);
修改字段名
alter table messages add update_at timestamp;
增加字段
alter table messages drop update_at;
删除字段
drop table messages;
删除表
select * from messages;
查询表中的所有数据
select name from messages where id=1;
查询表中id为1的数据的名字
select count(*) from messages where name='zhangsan';
查询表中name为zhangsan的数据条数
insert into messages values(1 , 'joyce', 'hehe', '2014-12-13 21:56:03');
insert into messages(name,text) values('joyce', 'heheda');
插入数据
update messages set name='qsq',article='hehe' where id=1;
更新数据
delete from messages where id=1;
删除数据
mysqldump -u root -p lovestory > lovestory.sql
导出lovestory数据库到lovestory.sql文件
mysqldump -u root -p lovestory messages > messages.sql
导出messages数据表到messages.sql文件
source e:/lovestory/lovestory.sql
导入数据库,数据表
mysqladmin -u root -p password 123456
set password for root@localhost = password('123456');
把root的密码改成123456
mysql基本语句的更多相关文章
- MySQL的语句执行顺序
MySQL的语句执行顺序 MySQL的语句一共分为11步,如下图所标注的那样,最先执行的总是FROM操作,最后执行的是LIMIT操作.其中每一个操作都会产生一张虚拟的表,这个虚拟的表作为一个处理的输入 ...
- strace追踪mysql执行语句
一.strace参数 strace是Linux环境下的一款程序调试工具,用来监察一个应用程序所使用的系统调用及它所接收的系统信息.追踪程序运行时的整个生命周期,输出每一个系统调用的名字,参数,返回值和 ...
- MySQL 基础语句
MySQL 基础语句 多个知识点 ----------------------------------------------------------------------------------- ...
- MySQL DELETE语句和TRUNCATE TABLE语句的区别
MySQL DELETE语句和TRUNCATE TABLE语句的区别 2010-10-08 16:05 佚名 互联网 字号:T | T 在MySQL数据库中,DELETE语句和TRUNCATE TAB ...
- 使用 xlrd 模块实现对excel 的读取、excel转json 、excel 转 mysql insert 语句
#-*- coding:utf-8 -*- # 处理 excel 中的 area 为 Mysql insert 语句 import xlrd, json, codecs, os # data = xl ...
- MySQL update语句和insert插入语句写法完全不一样啊,不要搞混
1.mysql update 语句: update user set name = 'xiaoming',age = 18 where uid = 3000; 更新记录时update操作也不需要写ta ...
- 最常用的MySQL命令语句
e良师益友网导读:MySQL数据库是应用最广的数据库之一,在MySQL数据库中有各种各样的命令调用语句,在平常工作中非常实用的命令,对于初学者来说,掌握文中的MySQL命令语句,是非常实用的,下面我们 ...
- MySQL 常用语句 (汇集)
原文地址:MySql常用语句作者:wuyanle 一.mysql常用语句 创建,删除和最基本查询: 显示数据库 mysql->show databases; 创建数据库 mysql-> ...
- mysql 插入语句
mysql 插入语句 什么时候用单引号,什么时候不用? 1.先创建一个表 create table user(username varchar(255),age int,marry boolean,b ...
- MySQL查询语句执行过程及性能优化(JOIN/ORDER BY)-图
http://blog.csdn.net/iefreer/article/details/12622097 MySQL查询语句执行过程及性能优化-查询过程及优化方法(JOIN/ORDER BY) 标签 ...
随机推荐
- Cross join in excel --- Copy from Internet
Set up the Workbook In this example, there are two tables -- Raw Materials and Packaging -- and each ...
- Ionic + AngularJS
Ionic Framework Ionic framework is the youngest in our top 5 stack, as the alpha was released in lat ...
- pdf.js pdfdom.js使用(转)
开篇语: 最近工作需要做一个借款合同,公司以前的合同都是通过app端下载,然后通过本地打开pdf文件,而喜欢创新的我,心想着为什么不能在线H5预览,正是这个想法,说干就干,实践过程总是艰难的,折腾了3 ...
- Week 1:2015/4/27~2015/5/3
Update everyday.(Last edit:4/30 01:00) Task 1:TPO X 2.5(finish 1,then finish 2 more) Task 2:TC Tarja ...
- vs2015启动网站调试提示 HTTP 错误 403.14 - Forbidden Web 服务器被配置为不列出此目录的内容。 解决方法
今天安装了vs2015 下载一个项目进行试用,启动调试的时候提示 HTTP 错误 403.14 - Forbidden Web 服务器被配置为不列出此目录的内容. 最可能的原因: 没有为请求的 URL ...
- linq操作文件方法
备忘 string directory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); List<File ...
- telnet输入乱码的解决
1.Win+R --- 运行窗口 输入cmd回车 2.输入telnet 主机 端口 3.连接主机发现无法输入 4.这里什么也不要输入,按下 ctrl+] 键 5.按下回车键,然后会弹出新的窗口,就可 ...
- Java class,Object,Class的区别
代码: http://www.cnblogs.com/hongdada/p/6060487.html package com.company; public class Main { public s ...
- 使用NUGet自动下载(还原)项目中使用的包
签出完整项目后,在解决方案名称上点右键,选择"启用NuGet程序包还原",如下图: 出现询问,当然要点是:是 当完成后,会发现在解决方案中,多出".nuget" ...
- Error : An error occurred while creating the WebJob schedule: Response status code does not indicate success: 409 (Conflict).
How to fix the error? the answer is simple switch from Free to Standard...