Mysql基础语句

 Navicat Premium 数据库管理工具

 

SQL语句:

数据库语句:

---查看当前数据库:
    show databases;
---创建数据库: create database dbname1
---进入数据库:
    use dbname1
---删除数据库:
drop database dbname1

 

 

 

数据表语句:

---查看数据表:
    show tables;
---创建数据表:
    create table _category(id int primary key auto_increment,name varchar(50),description varchar(200);
---根据已有的表创建新表:    A:create table tab_new like tab_old (使用旧表创建新表) B:create table tab_new as select col1,col2… from tab_old definition only
---添加一列: alter table table_name add field3 int
---删除列: alter table table_name drop field3
---删除数据表:   drop table table_name

 

使用工具创建表:(Navicat)

 

基础sql语句:

---查找:
    select * from table1 where accounts='100100'
---插入: insert into table1 (field1,field2) values(value1,value2)
---更改: update table1 set field1=value3 where 范围
---删除: delete from table1 where 范围
---查找(like) select * from table1 where field1 like '%value1%'
---排序(order by) select * from table1 order by field1 desc
---总数: select count as totalcount from table1
---求和: select sum(field1) as sumvalue from table1
---平均: select avg(field1) as avgvalue from table1
---最大: select max(field1) as maxvalue from table1
---最小: select min(field1) as minvalue from table1

 

posted @ 2018-05-09 09:41  happy_xiaoxiao  Views(143)  Comments(0Edit  收藏  举报