弱智问题一:
在往MySql的表中插数据时,老是报SQL Error: 1064, SQLState: 42000错误,郁闷了好半天,上网搜了才发现,是因为表中字段的名字用了MySql的关键字,晕倒,以后一定要注意。
MySQL的保留字有以下这些,使用中需要注意。(从网上打劫过来的)
ADD | ALL | ALTER |
ANALYZE | AND | AS |
ASC | ASENSITIVE | BEFORE |
BETWEEN | BIGINT | BINARY |
BLOB | BOTH | BY |
CALL | CASCADE | CASE |
CHANGE | CHAR | CHARACTER |
CHECK | COLLATE | COLUMN |
CONDITION | CONNECTION | CONSTRAINT |
CONTINUE | CONVERT | CREATE |
CROSS | CURRENT_DATE | CURRENT_TIME |
CURRENT_TIMESTAMP | CURRENT_USER | CURSOR |
DATABASE | DATABASES | DAY_HOUR |
DAY_MICROSECOND | DAY_MINUTE | DAY_SECOND |
DEC | DECIMAL | DECLARE |
DEFAULT | DELAYED | DELETE |
DESC | DESCRIBE | DETERMINISTIC |
DISTINCT | DISTINCTROW | DIV |
DOUBLE | DROP | DUAL |
EACH | ELSE | ELSEIF |
ENCLOSED | ESCAPED | EXISTS |
EXIT | EXPLAIN | FALSE |
FETCH | FLOAT | FLOAT4 |
FLOAT8 | FOR | FORCE |
FOREIGN | FROM | FULLTEXT |
GOTO | GRANT | GROUP |
HAVING | HIGH_PRIORITY | HOUR_MICROSECOND |
HOUR_MINUTE | HOUR_SECOND | IF |
IGNORE | IN | INDEX |
INFILE | INNER | INOUT |
INSENSITIVE | INSERT | INT |
INT1 | INT2 | INT3 |
INT4 | INT8 | INTEGER |
INTERVAL | INTO | IS |
ITERATE | JOIN | KEY |
KEYS | KILL | LABEL |
LEADING | LEAVE | LEFT |
LIKE | LIMIT | LINEAR |
LINES | LOAD | LOCALTIME |
LOCALTIMESTAMP | LOCK | LONG |
LONGBLOB | LONGTEXT | LOOP |
LOW_PRIORITY | MATCH | MEDIUMBLOB |
MEDIUMINT | MEDIUMTEXT | MIDDLEINT |
MINUTE_MICROSECOND | MINUTE_SECOND | MOD |
MODIFIES | NATURAL | NOT |
NO_WRITE_TO_BINLOG | NULL | NUMERIC |
ON | OPTIMIZE | OPTION |
OPTIONALLY | OR | ORDER |
OUT | OUTER | OUTFILE |
PRECISION | PRIMARY | PROCEDURE |
PURGE | RAID0 | RANGE |
READ | READS | REAL |
REFERENCES | REGEXP | RELEASE |
RENAME | REPEAT | REPLACE |
REQUIRE | RESTRICT | RETURN |
REVOKE | RIGHT | RLIKE |
SCHEMA | SCHEMAS | SECOND_MICROSECOND |
SELECT | SENSITIVE | SEPARATOR |
SET | SHOW | SMALLINT |
SPATIAL | SPECIFIC | SQL |
SQLEXCEPTION | SQLSTATE | SQLWARNING |
SQL_BIG_RESULT | SQL_CALC_FOUND_ROWS | SQL_SMALL_RESULT |
SSL | STARTING | STRAIGHT_JOIN |
TABLE | TERMINATED | THEN |
TINYBLOB | TINYINT | TINYTEXT |
TO | TRAILING | TRIGGER |
TRUE | UNDO | UNION |
UNIQUE | UNLOCK | UNSIGNED |
UPDATE | USAGE | USE |
USING | UTC_DATE | UTC_TIME |
UTC_TIMESTAMP | VALUES | VARBINARY |
VARCHAR | VARCHARACTER | VARYING |
WHEN | WHERE | WHILE |
WITH | WRITE | X509 |
XOR | YEAR_MONTH | ZEROFILL |
弱智问题二:
需要同事帮忙调整程序,但是同事却死人的连不上我机器上的MySql,继续郁闷,继续网上搜索。
发现一个补救办法是:让mysql库中user表的host字段为“%”,以接受远程控制,这样别人就可以用mysql -h ***.***.***.***(你的IP) -u root -p密码 进行连接并操作数据库了。
还有一个是在安装时需要注意的:在设置用户的时候会有一个复选框,问是否让别人连接,这里需要选中!
弱智问题三:
用Hibernate,设置PO映射文件的主键字段的属性为“natively”(<id name="logId" type="integer" column="LOGID"><generator class="native"/></id>),但是往表里面查数据时老是说“The database returned no natively generated identity value”。
最后确认是在表的属性中没有设置主键为“auto increment”,这个可以用数据库连接工具在表属性中设置,也可以在建表的时候,在主键字段后面标注上:CREATE TABLE `log` (`LOGID` int(11) NOT NULL auto_increment, PRIMARY KEY (`LOGID`)) ENGINE=InnoDB DEFAULT CHARSET=gbk
弱智问题四:
做报表的时候,需要查出内容为Null的记录,在查询条件里面写了“XX=null”,结果怎么也查不出来,郁闷半天,后来试了下“XX is null”,就查出来了,哎,俺真是够白痴的了!