建库、建表、插入、查询数据一键操作
文章目录
格式:
create database 数据库名 charset utf8; use 数据库名; create table 表名(字段名1 字段类型 [字段属性], 字段名2 字段类型 [字段属性], ....); insert into 表名(字段名1, 字段名2, ...)
values(值1, 值2, ...); select * from 表名;例如1:
create database demo1 charset utf8; use demo1; create table info(id int auto_increment primary key, title varchar(50), email varchar(20), content text); insert into info( id, title, email, content)
values(null, '今天我们可以不上自习吗?', '1871151400@qq.com', '不可以!'); select * from info;例如2:
create table news(nid smallint auto_increment primary key not null, cid tinyint not null, title varchar(50) not null, author varchar(20), source varchar(20), keywords varchar(120), description varchar(100), orderby tinyint not null default 50, content text, hits smallint not null default 0, addate int); 效果图如下

例如3:
create table user(id int auto_increment primary key not null, username varchar(20) not null, password char(32) not null, name varchar(16) not null, tel varchar(50) not null, last_login_ip char(15) default null, last_login_time int(10) default null, login_times int(11) not null default 0, status smallint(1) not null default 1, role tinyint(1) not null default 0, addate int(10) not null);效果图如下

例如4:
// 创建文章数据表article
CREATE TABLE IF NOT EXISTS `article8`(
`id` int not null auto_increment primary key, # 编号
`category_id` smallint, # 文章分类ID
`user_id` smallint, # 用户ID
`title` varchar(30), # 文章标题
`content` text, # 文章内容
`orderby` tinyint not null default 0, # 排序字段
`comment_count` int not null default 0, # 评论数
`top` tinyint not null default 0, # 是否置顶, 1置顶, 0不置顶
`read` int not null default 0, # 阅读数
`praise` int not null default 0, # 点赞数
`addate` int(10) # 发布时间
)ENGINE=MyISAM;效果图如下

之后可以做其他操作
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论