auto-increment

Auto increment with XQuery Update?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 01:24:20
问题 Does XQuery Update support auto increment attributes, just like auto increment fields in SQL ? I'm using BaseX as my database. 回答1: Given an answer from Christian Grün on the BaseX mailing list, this is doable when the node one is adding is defined in the XQuery Update statement, and hence can be enhanced using an {enclosed expression} before inserting it: You might specify the attribute counter within your XML file/database and increment it every time when you insert an element. A simple

Adding auto-incremented values to a table with one column

与世无争的帅哥 提交于 2019-12-07 18:15:40
问题 I need to create a table that basically keeps a list of indices only. Therefore I've created a table with just one, auto-incremented column called 'id'. However, I can't seem to implicitly add auto-incremented values to this table. I know that usually when you have such a column in a table (with more than just this column) you can do: INSERT INTO TABLE (col1, col2 ...) VALUES (val1, val2 ...) And if you don't specify the auto-incremented column, it would automatically get a value. However,

hibernate not generate auto increment constraint on mysql table

守給你的承諾、 提交于 2019-12-07 17:58:44
问题 I have been searching through different forums for the problem and had tried different solutions but i am still unable to find any correct answer for my problem. I am using hibernate4 annotations for mapping my entities. everything works fine but only auto increment key is not detected when tables are created using hibernate in mysql. i have following code: @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(unique = true, nullable = false) private int responseId; i also have

Auto-incrementation with HSQLDB (2.2.8) + DDLUtils

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 16:49:26
I want to use HSQLDB as an embedded database but am having trouble getting it to auto-increment . As far as I understand, [CALL] IDENTITY() can be used to get the last primary key value. However, experiments through both iBatis and HSQLDB's DatabaseManagerSwing continually return a 0 value. How can I get auto-incrementation to work with HSQLDB? Edit: I didn't mention that I'm using DDLUtils to autogenerate tables. The following does not suit HSQLDB: <?xml version="1.0"?> <!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database.dtd"> <database name="testdb"> <table name="users"> <!--

mySQL Database: Reset AutoIncrement Fields

▼魔方 西西 提交于 2019-12-07 15:54:03
问题 while the development of websites we use the database to test & all... which consumes a lot from auto generated (auto increment) attributes series... how to reset everything... 回答1: Assuming you're deleting the records when you're done testing, a TRUNCATE command will delete all records and reset the autoincrement value. 回答2: ALTER TABLE _TABLE_ AUTO_INCREMENT=1 回答3: Another possibility, avoiding transactions and resetting the autoincrement counter could be to combine the select to get the

Resetting auto-increment column back to 0 daily

微笑、不失礼 提交于 2019-12-07 07:58:41
问题 Is there a way in postgresql to have an auto-incrementing column reset back to zero at a specified time every day? 回答1: It could be pretty trivial with a cronjob 0 0 * * * echo "SELECT setval('public.my_table_id_seq', 1, false)" | psql -U my_db_user -d my_db_name Alternately, you could set your "serial" column DEFAULT to call a stored procedure, which would check for a day rollover, reset the sequence if appropriate, and then return the result of nextval(). But other than that, no, I wouldn't

prevent autoincrementing integer primary key?

蹲街弑〆低调 提交于 2019-12-07 06:43:16
问题 I have a sqlite table (sqlite version 3.7.3) where nulls inserted into the primary key column are being undesirably auto-incremented: sqlite> CREATE TABLE foo(bar INTEGER NOT NULL PRIMARY KEY); sqlite> INSERT INTO foo(bar) VALUES(NULL); sqlite> SELECT * FROM foo; 1 In the sqlite docs, it shows that adding the AUTOINCREMENT keyword to the column should create this behavior, but there doesn't appear to be a keyword to prevent the auto incrementing... I also found that I can build sqlite with

How is the MySQL auto_increment step size determined

随声附和 提交于 2019-12-07 02:56:45
问题 I have a table of web pages, with the primary key as hash of the URL, and an auto_increment ID column, which is also a unique key. What I'm a bit confused by is why successive inserts don't increment the ID field by 1. When I first created the table and did a single insert, the first id was 1. The second insert produced and id of 5 and the third was 8. I have a trigger on the table which, on insert, computes the hash of the URL of the webpage. Not sure if that's relevant or not. It's not a

postgresql nextval generating existing values

风格不统一 提交于 2019-12-07 02:26:43
问题 I had to migrate from a mySql based ruby on rails app to using postgresql. No problems but one so far, and I don't know how to solve it. The migration of data brought ids along with it, and postgresql is now having problems with existing ids: it's not clear to me where it gets the value that it uses to determine the base for nextval: it certainly isn't the highest value in the column, although you might think that would be a good idea. In any case, it's now colliding with existing id values.

Arithmetic overflow error converting IDENTITY to data type tinyint

妖精的绣舞 提交于 2019-12-07 01:52:39
问题 I am designing table in SQL Server 2008 R2 SP2 Express database. I created table with nvarchar column for data and tinyint column for auto-incrementing identity assuming there will be no more than few rows (that's why I choose 0-255 tinyint ). When I add more than 255 rows, this error keeps occurring permanently even after I delete all rows in that table and try to add one new row. I am doing this using SQL Server Management Studio Express. How to force database engine to check what indexes