Home > Back-end >  The database
The database

Time:09-26

INSERT data in SQL, the prompt can't INSERT the explicit values timestamp columns of column list, please use the INSERT to remove timestamp columns, is a timestamp type of problem, so can't modify the data in the table to INSERT structure? One per is timestamp types in the database, represents the current time,

SQLSTR:='insert into' + '+' vv_ova (id, pipenum D_ova, X_ova, D_cir, X_cir, D_str, X_str, per) values (: : s0 and s1, s2, : s3, : s4, : s5, : s6, : s7, : s8) ';
ADOQuery1. SQL. The Add (SQLSTR);
ADOQuery1. The Parameters. ParamByName (' s0). Value:=trim (Edit1. Text);
ADOQuery1. The Parameters. ParamByName (' s1 '). The Value:=trim (Edit2. Text);
ADOQuery1. The Parameters. ParamByName (' s2). The Value:=trim (Edit3. Text);
ADOQuery1. The Parameters. ParamByName (" s3 "). The Value:=trim (Edit4. Text);
ADOQuery1. The Parameters. ParamByName (' s4 '). The Value:=trim (Edit5. Text);
ADOQuery1. The Parameters. ParamByName (' s5). Value:=trim (Edit6. Text);
ADOQuery1. The Parameters. ParamByName (' s6 '). The Value:=trim (Edit7. Text);
ADOQuery1. The Parameters. ParamByName (' s7). Value:=trim (Edit8. Text);
ADOQuery1. The Parameters. ParamByName (' the s8). Value:=trim (Edit9. Text);


Tips for SQL explicit values can not be inserted into the timestamp column, please use the column list INSERT to exclude timestamp columns, or INSERT DEFAULT timestamp columns,

CodePudding user response:

Timestamp column should can't be assignment, this is the system automatically generated, insert automatically generated, update, will follow the updated.



Timestamp (Transact - SQL)

Public database automatically generated only binary digital data type, timestamp is usually used for to the table row version timestamp mechanism, storage size is 8 bytes, the timestamp data type is increasing Numbers, no reservation date or time, if you want to record the date or time, please use the datetime data type,

Note
Each database has a counter, when on a database containing timestamp column of table insert or update operation, the counter value will increase, the time stamp counter is database, it can track the relative time inside the database, rather than the real time clock phase correlation, a table can have only a timestamp column, every change or insert contains a timestamp column row will be inserted in the timestamp column incremental database timestamp values, this property makes the timestamp column is not suitable for use as the key, cannot be used as the primary key, in particular, to do any update would change the timestamp values, so as to change the key value, if the column as part of the primary key, so the old keys will be invalid, and reference the old value of the foreign key will also no longer effective, if the table references in the dynamic cursors, all updates will change the location of the cursor is the bank of China, if it belongs to index key columns, with data rows all updates will also lead to index updates,

Use timestamp column in a row can be easily to determine whether any of its value since the last read later changed, if the line for the change, will update the timestamp values, if there is no line to make changes, then the timestamp values will be consistent with the timestamp values during read it before, if you want to return to the database of the current timestamp values, please use the @ @ DBTS,

Transact - SQL the timestamp data type is different from the SQL - 2003 standard defined in the timestamp data type, the SQL - 2003 the timestamp data type is equivalent to Transact - SQL datetime data type,

Rowversion data type is timestamp data types of synonyms, and a data type, the behavior of the synonyms in the DDL statement, please use rowversion rather than the timestamp, for details please refer to the data type synonyms (Transact - SQL),

In the CREATE TABLE or ALTER TABLE statement, don't need to specify the column name for the timestamp data type, such as:

Copy the code
The CREATE TABLE ExampleTable (PriKey int PRIMARY KEY, timestamp); If you do not specify the column name, Microsoft SQL Server 2005 database engine will generate timestamp column names; But rowversion synonyms does not have such behavior, when using rowversion, must specify the column name,

Note:
In the use of the SELECT list with a timestamp column of the SELECT INTO statement, may generate repetitive timestamp values, in this way is not recommended to use timestamp,



An empty timestamp column on semantic equivalent binary (8) column, the timestamp column can be null in semantically equivalent to varbinary (8) column,

CodePudding user response:

In a word, the timestamp column is generated by issue or update, it is to identify the bank data update time mark, you don't have to set it,
  • Related