-- 查看有哪些用户 host: % 代表任意地址都可以登录 host: localhost 代表仅本地可以连接
select host,user from mysql.user; -- 建库
create database test charset utf8;
-- 刷新
flush privileges
-- 赋权
grant all on *.* to 'admin'@'%'; 将数据库的权限赋给admin用户 
-- 刷新
-- 查看建库过程
show create database test;
-- 选择数据库
use test;
-- 建表
create table test(
name varchar(20),
age int
);
-- 修改表名
alter table test rename new_test; -- 查看建表过程
show create table test;
  show create table test\G -- 格式化输出
-- 查看表结构
describe test; -- 等同show columns from user;
-- 查看表内容
select * from test;
-- 添加内容
insert into test values('tj',18);
insert into test(name) values('tj1');
insert into test(age) values(19);
insert into test(age,name) values(19,'tt');
insert into test values('a',1),('b',2);
-- 查看表内容
select * from test; -- 改内容update(可修改名字及数值)
update test set name='updat' where age=19; -- 不加条件则修改所有的
update test set age=20 where name = 'updat'; -- 不加条件则修改所有的
-- 查看表内容
select * from test; -- 删除内容delete
delete from test where age =1; -- 不加条件则删除整个表的内容
delete from test where age<=>null; -- 删除age为null的数据
-- 查看表内容
select * from test; -- 修改表结构及属性 add增加,change重命名,drop删除,modify修改
-- add 给表添加新的结构
alter table test add gender char(5) default '不知';
-- change 将表头名name 改为username
alter table test change name username varchar(20);
-- drop删除
alter table test drop age; -- 就没有了age属性
alter table test add age char(5) default 18 after username;
-- modify修改属性,不能修改名字
alter table test modify age char(6);
-- 查看建表过程
show create table test;
-- 查看表内容
select * from test; -- 常用的数值类型
create table test1(
a varchar(10) not null,
b char(10) default 'zz',
c text,
d int null,
e tinyint null,
f datetime default '2017-12-21 16:21:10'
);
describe test1;
insert into test1 values('tj','hello','hello',18,17,'1999-9-9 09:09:09');
select * from test1; -- drop table xxx 删除表
-- drop database * 删除所有表

msq_table's methods的更多相关文章

  1. How to implement equals() and hashCode() methods in Java[reproduced]

    Part I:equals() (javadoc) must define an equivalence relation (it must be reflexive, symmetric, and ...

  2. Sort Methods

    heyheyhey ~~ It has been a long time since i come here again...whatever today i will summerize some ...

  3. Top 10 Methods for Java Arrays

    作者:X Wang 出处:http://www.programcreek.com/2013/09/top-10-methods-for-java-arrays/ 转载文章,转载请注明作者和出处 The ...

  4. Don’t Use Accessor Methods in Initializer Methods and dealloc 【初始化和dealloc方法中不要调用属性的存取方法,而要直接调用 _实例变量】

    1.问题:    在dealloc方法中使用[self.xxx release]和[xxx release]的区别? 用Xcode的Analyze分析我的Project,会列出一堆如下的提示:Inco ...

  5. C# Extension Methods

    In C#, extension methods enable you to add methods to existing class without creating a new derived ...

  6. CLR via C# 3rd - 08 - Methods

       Kinds of methods        Constructors      Type constructors      Overload operators      Type con ...

  7. 转 Dynamics CRM Alert and Notification JavaScript Methods

    http://www.powerobjects.com/2015/09/23/dynamics-crm-alert-and-notification-javascript-methods/ Befor ...

  8. AX7: HOW TO USE CLASS EXTENSION METHODS

    AX7: HOW TO USE CLASS EXTENSION METHODS   To create new methods on a standard AX class without custo ...

  9. Keeping Async Methods Alive

    Consider a type that will print out a message when it’s finalized, and that has a Dispose method whi ...

随机推荐

  1. Maps.newHashMapWithExpectedSize(2)

    ☆ Map<String, Object> diffQuota = Maps.newHashMapWithExpectedSize(2); Maps.newHashMapWithExpec ...

  2. test20180907 day1

    T1 256MB,1Sec T2 512MB,3Sec T3 512MB,1Sec 总分:150 试题一 餐馆 题目背景 铜企鹅是企鹅餐馆的老板,他正在计划如何使得自己本年度收益增加. 题目描述 共有 ...

  3. 【MVC】View的使用

    /Views/_ViewStart.cshtml 文件会在其他视图文档被加载之前被载入,代码如下: @{ Layout = "~/Views/Shared/_Layout.cshtml&qu ...

  4. JS页面打印预览功能

    点击按钮后就可以直接打印预览,并且隐藏了按钮,如果你不希望按钮显示,可以把那部分代码删除就可以了. <html><head><meta http-equiv=" ...

  5. maven 知识点1

    在POM 4中,dependency 中还引入了 scope,它主要管理依赖的部署.目前 scope 可以使用5个值: compile,缺省值,适用于所有阶段,会随着项目一起发布. provided, ...

  6. 洛谷1352没有上司的舞会——树型dp

    题目:https://www.luogu.org/problemnew/show/P1352 #include<iostream> #include<cstdio> using ...

  7. Angular 4 组件间的通信

    一.输入属性(父组件与子组件通信) 1. 创建工程 ng new demo1 2.创建order组件 ng g component order 3. 在order组件里定义输入属性 order组件的h ...

  8. dedecms问答模块时间显示1970-01-01的解决办法

    在使用dedecms的问答模块的时候,很多人希望能在模板上加上问题的时间,一般我们采用这样的dede标签: {dede:ask row=24 titlelen='50' sort='ok'}   &l ...

  9. 如何判断事务是否完成,SqlTransaction

    SqlConnection sconn = null; SqlCommand scmd = null; SqlTransaction strans = null; try { string sqlIn ...

  10. MVC框架请求处理

    为开发团队选择一款优秀的MVC框架是件难事儿,在众多可行的方案中决择需要很高的经验和水平.你的一个决定会影响团队未来的几年.要考虑方面太多: 简单易用,以提高开发效率.使小部分的精力在框架上,大部分的 ...