SQL: The primary key of a data table is a varchar type, does not increment, how to insert a primary key when inserting data
Reply content:
SQL: The primary key of a data table is a varchar type, does not increment, how to ins
At the beginning of this demand, in the online search, found all said no, you have to delete the primary key column and then re-add or create a temporary table before the data, in fact, can be directly modified in MySQL.Modify the ID field to self-increment the primary key:ALTER TABLE ' Test ' change ' ID ' ' id ' int (one) UNSIGNED not NULL auto_increment, add
If the database uses multiple fields instead of just one as the primary key, that is, the Federated primary key, this time you can use Hibernate to provide a federated primary key generation strategy.Specific as follows:You can us
Today the project encountered this problem, engaged in the majority of days, I am depressed ...Hibernate Federated Primary Key configuration (multiple fields together as primary key)Generate files for primary keyspublic class Bbwjjcid implements Java.io.Serializable {Private
Hibernate the primary key generation policy
All primary key generators implement the Org.hibernate.id.TableLoGenerator interface
The following is a discussion of the shortcut name of the Hibernate built-in generator and the use of
Divided into the following categories:
Increment,identity,sequence,
Hilo, Seqhilo,
By default, the Oracle view does not have a primary key. Therefore, when a java class is generated in reverse direction using hibernate, a composite primary key is automatically used to generate a class name + ID, Which is troublesome for later development.
Therefore, adding a pri
Tags: Oracle primary key1. Delete the primary key ALTER table TABLENAME drop Primary_key Execute the above SQL to remove the primary key; If unsuccessful, you can use ALTER TABLE TABLENAME drop CONSTRAINTS COLUMN Cascad E --delete constraint alter TABLE TABLENAME DISABLE Pri
Hibernate @ TableGenrator table management primary key generation policy, hibernate primary key generation@ TableGenerator: generates a table in the database to manage the primary key generation policy.ImpOrt javax. persistence. T
Oracle version:Sql> select * from V$version;
BANNER----------------------------------------------------------------Oracle9i Enterprise Edition Release 9.2.0.6.0-productionPl/sql Release 9.2.0.6.0-productionCORE 9.2.0.6.0 Production
TNS for 32-bit windows:version 9.2.0.6.0-productionNlsrtl Version 9.2.0.6.0-production
***************************************************************** * When you create a primary key
Create PROCEDURE pro_test (@userName NVARCHAR ( -) ) as--Select* from[dbo]. [Table_2]--SELECT *From [dbo]. [Student] Beginbegin TRAN DECLARE @tempTable TABLE (tempid uniqueidentifier) DECLARE @tempId uniqueidentifier INSERT into tabl E_2 (UserName) OUTPUT Inserted.userid into @tempTable VALUES (@userName)--insert data into the first table SELECT @tempId=tempid from @tempTable--assign a value to the middle variable INSERT into dbo. Student (Stuname, Stuage, Stusex,stucode) VALUES ('Zhansan',Ten,'
Oracle sequence detailing and creating a self-added primary key
Oracle Sequence PRIMARY KeySequence: A database object provided by Oacle to produce a series of unique digits.L provide a unique numeric value automaticallyL Shared objectsL primarily used to provide primary key
ainner join position pp on pp. lngpositionid =. flnginpositionidleft join employee e on e. lngemployeeid =. flngemployeeidwhere. flnginid
The preceding is a view in Oracle. This view is always not added several times.
The view is not added after vertices.
The reason is that in view SQL, the union all keyword EF cannot infer which is the primary key.
Solution:
First, delete the SQL statements under union
--alter table Historydata drop constraint Pk_historydataALTER TABLE HISTORYDATA ADD constraint Pk_historydata primary key (Collectiontime,code)Change primary keyDelete from Historydata where collectiontime between ' 2014-09-01 00:00:00 ' and ' 2014-11-01 00:00:00 ' and ID not in (Select ID from (Select Code,collectiontime,max (ID) ID from historydatawhere collect
The test results are: count (*) and COUNT (1) are basically equal, count (non-primary key field) is the most cost-consuming--Data Volume 708254Select COUNT (*) from tmp_test1;--avg 0.2240.2290.2190.2270.2220.2150.2240.2250.2210.2400.219Select COUNT (1) from tmp_test1;--avg 0.2260.2300.2170.2170.2330.2250.2200.2350.2320.2330.219Select COUNT (ID) from tmp_test1;--avg 0.2380.2400.2420.2300.2500.2340.2330.2400.
What are the differences among KEY, primary key, unique key, and INDEX in MySQL? mysqlunique
You can split the questions raised in the questions to solve them step by step. In MySQL, KEY and INDEX are synonymous. This problem can be simplified to the difference between
This article mainly introduces the specific definition and usefulness of super-key, candidate key, primary key, main attribute, foreign key in MySQL database. You can also refer to the topic.alibabacloud.com MySQL video tutorial and
MySQL manual。
First look at the definitio
In mysql, key, primary key, unique key and index are different, mysqlunique
Indexes in mysql are very important knowledge points. Compared with other knowledge points, indexes are more difficult to master, and there are many index types in mysql, such as primary
Tags: Describes res family implementation requires DOM field a bleTransferred from: http://zccst.iteye.com/blog/1697043 one, key and primary key difference CREATE TABLEWh_logrecord (logrecord_idint( One) not NULLAuto_increment,user_name varchar( -)default NULL, Operation_timedatetime default NULL, Logrecord_operationvarchar( -)default NULL,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.