gpt4 book ai didi

java - 为大量列准备的声明

转载 作者:行者123 更新时间:2023-11-29 13:42:26 26 4
gpt4 key购买 nike

我有一个包含 74 列的表,我想向其中插入数据。有没有办法在该表中只插入 5 列并将其余列保留为空?这些列也没有按顺序排列,可能是

    ps.setInt(1, 1);
ps.setInt(7, "Steve");
ps.setInt(10, time);

等等......

我必须为每一列填写数据吗?

表的结构:

CREATE TABLE IF NOT EXISTS `vbulletin_user` (
`userid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`usergroupid` smallint(5) unsigned NOT NULL DEFAULT '0',
`membergroupids` char(250) NOT NULL DEFAULT '',
`displaygroupid` smallint(5) unsigned NOT NULL DEFAULT '0',
`username` varchar(100) NOT NULL DEFAULT '',
`password` char(32) NOT NULL DEFAULT '',
`passworddate` date NOT NULL DEFAULT '0000-00-00',
`email` char(100) NOT NULL DEFAULT '',
`styleid` smallint(5) unsigned NOT NULL DEFAULT '0',
`parentemail` char(50) NOT NULL DEFAULT '',
`homepage` char(100) NOT NULL DEFAULT '',
`icq` char(20) NOT NULL DEFAULT '',
`aim` char(20) NOT NULL DEFAULT '',
`yahoo` char(32) NOT NULL DEFAULT '',
`msn` char(100) NOT NULL DEFAULT '',
`skype` char(32) NOT NULL DEFAULT '',
`showvbcode` smallint(5) unsigned NOT NULL DEFAULT '0',
`showbirthday` smallint(5) unsigned NOT NULL DEFAULT '2',
`usertitle` char(250) NOT NULL DEFAULT '',
`customtitle` smallint(6) NOT NULL DEFAULT '0',
`joindate` int(10) unsigned NOT NULL DEFAULT '0',
`daysprune` smallint(6) NOT NULL DEFAULT '0',
`lastvisit` int(10) unsigned NOT NULL DEFAULT '0',
`lastactivity` int(10) unsigned NOT NULL DEFAULT '0',
`lastpost` int(10) unsigned NOT NULL DEFAULT '0',
`lastpostid` int(10) unsigned NOT NULL DEFAULT '0',
`posts` int(10) unsigned NOT NULL DEFAULT '0',
`reputation` int(11) NOT NULL DEFAULT '10',
`reputationlevelid` int(10) unsigned NOT NULL DEFAULT '1',
`timezoneoffset` char(4) NOT NULL DEFAULT '',
`pmpopup` smallint(6) NOT NULL DEFAULT '0',
`avatarid` smallint(6) NOT NULL DEFAULT '0',
`avatarrevision` int(10) unsigned NOT NULL DEFAULT '0',
`profilepicrevision` int(10) unsigned NOT NULL DEFAULT '0',
`sigpicrevision` int(10) unsigned NOT NULL DEFAULT '0',
`options` int(10) unsigned NOT NULL DEFAULT '33570831',
`birthday` char(10) NOT NULL DEFAULT '',
`birthday_search` date NOT NULL DEFAULT '0000-00-00',
`maxposts` smallint(6) NOT NULL DEFAULT '-1',
`startofweek` smallint(6) NOT NULL DEFAULT '1',
`ipaddress` char(15) NOT NULL DEFAULT '',
`referrerid` int(10) unsigned NOT NULL DEFAULT '0',
`languageid` smallint(5) unsigned NOT NULL DEFAULT '0',
`emailstamp` int(10) unsigned NOT NULL DEFAULT '0',
`threadedmode` smallint(5) unsigned NOT NULL DEFAULT '0',
`autosubscribe` smallint(6) NOT NULL DEFAULT '-1',
`pmtotal` smallint(5) unsigned NOT NULL DEFAULT '0',
`pmunread` smallint(5) unsigned NOT NULL DEFAULT '0',
`salt` char(30) NOT NULL DEFAULT '',
`ipoints` int(10) unsigned NOT NULL DEFAULT '0',
`infractions` int(10) unsigned NOT NULL DEFAULT '0',
`warnings` int(10) unsigned NOT NULL DEFAULT '0',
`infractiongroupids` varchar(255) NOT NULL DEFAULT '',
`infractiongroupid` smallint(5) unsigned NOT NULL DEFAULT '0',
`adminoptions` int(10) unsigned NOT NULL DEFAULT '0',
`profilevisits` int(10) unsigned NOT NULL DEFAULT '0',
`friendcount` int(10) unsigned NOT NULL DEFAULT '0',
`friendreqcount` int(10) unsigned NOT NULL DEFAULT '0',
`vmunreadcount` int(10) unsigned NOT NULL DEFAULT '0',
`vmmoderatedcount` int(10) unsigned NOT NULL DEFAULT '0',
`socgroupinvitecount` int(10) unsigned NOT NULL DEFAULT '0',
`socgroupreqcount` int(10) unsigned NOT NULL DEFAULT '0',
`pcunreadcount` int(10) unsigned NOT NULL DEFAULT '0',
`pcmoderatedcount` int(10) unsigned NOT NULL DEFAULT '0',
`gmmoderatedcount` int(10) unsigned NOT NULL DEFAULT '0',
`assetposthash` varchar(32) NOT NULL DEFAULT '',
`fbuserid` varchar(255) NOT NULL DEFAULT '',
`fbjoindate` int(10) unsigned NOT NULL DEFAULT '0',
`fbname` varchar(255) NOT NULL DEFAULT '',
`logintype` enum('vb','fb') NOT NULL DEFAULT 'vb',
`fbaccesstoken` varchar(255) NOT NULL DEFAULT '',
`newrepcount` smallint(5) unsigned NOT NULL DEFAULT '0',
`bloggroupreqcount` int(10) unsigned NOT NULL DEFAULT '0',
`showblogcss` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`userid`),
KEY `usergroupid` (`usergroupid`),
KEY `username` (`username`),
KEY `birthday` (`birthday`,`showbirthday`),
KEY `birthday_search` (`birthday_search`),
KEY `referrerid` (`referrerid`),
KEY `fbuserid` (`fbuserid`),
KEY `email` (`email`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

最佳答案

正如 Luiggi Mendoza 在评论中所说,查询将起作用。
此查询中的示例:

ps=conn.prepareStatement("INSERT INTO vbulletin_user(userid,username,password,email) VALUES(?,?,?,?)");
ps.setInt(1,1);
ps.setString(2,"scott");
ps.setString(3,"tiger");
ps.setString(4,"email@example.com");

将插入架构中提到的其他列的默认值。
并且您应该将 Date 的默认值设置为某个特定日期,而不是像 passworddatebirthday_search 中那样的 0000-00-00 列,因为它会导致 some exception when accessing by java

java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date


这是 Fiddle ,在此我只是更改了 passworddatebirthday_search 列的 default date 值。

关于java - 为大量列准备的声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17903675/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com