温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

mysql数据库创建表

发布时间:2020-05-31 10:07:19 来源:网络 阅读:745 作者:Rockycai 栏目:数据库

记录自己创建数据库,需要更具情况修改



这是以一个学生查分系统作为例子:


create table info( 

student_id int not null auto_increment,   //会自动加值,而且是主键

name char(10), 

password char(8) not null default "12345678",   //设置默认值是

chinese int(2) default 0, 

math int(2) default 0, 

english int(2) default 0,

Chemistry int(2) default 0, 

Physics int(2) default 0,

time timestamp not null default current_timestamp,  //会自动获取时间,不需要插入

PRIMARY KEY (student_id)

)ENGINE=InnoDB DEFAULT CHARSET=utf8;    //设置默认编码



插入数据

insert into info(

student_id,name,password,chinese,math,english,Chemistry,Physics) 

values 

(  "2016102401","蔡小先生","19941024",80,90,80,89,95);


删除表中一行的数据

delete from info where student_id=2016102406;



//-------------------------------------

 student_id | name         | password | chinese | math | english | Chemistry | Physics | time                |

+------------+--------------+----------+---------+------+---------+-----------+---------+---------------------+

| 2016102401 | 蔡小先生     | 19941024 |      80 |   90 |      80 |        89 |      95 | 2016-11-19 00:16:11 |


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI