Home > php教程 > php手册 > mysql sql语句总结(不断更新中.........)

mysql sql语句总结(不断更新中.........)

WBOY
Release: 2016-06-06 20:01:45
Original
1042 people have browsed it

create database mytest default charset=utf8 //创建数据库 create table users //创建表 ( user_id int not null auto_increment, user_name varchar(20) not null, description varchar(200), primary key PK_userid(user_id) ); show create table users


create database mytest default charset=utf8  //创建数据库

create table users  //创建表
(
 user_id int not null auto_increment,
 user_name varchar(20) not null,
 description varchar(200),
 primary key PK_userid(user_id)
);

show create table users;//查看创建表的sql语句

desc users;  //查看表结构

alter table users add(user_age int not null); //添加表字段

insert into users(user_name,description,user_age) values('chen','this is good men.',28); //插入一条数据

//查询数据库

select * from users limit 5; //查询前5条

SELECT * FROM users LIMIT 6,2; //从第6条开始(包括),查2条

 

//查看表的数据结构
SHOW COLUMNS FROM tablename;
查出后以下字段:
Field type Null key default extra

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template