Deletes all indexes of the specified table, including primary key indexes, unique indexes, and normal indexes, for SQL Server 2005,Instructions for use:1. Execute the script first to create the stored procedure in the database2, call the method, take the gold partner database as an exampleUse VELCROMFM--database name, replace with specific itemGoDECLARE @tableNam
From: http://www.javaeye.com/topic/215571
In the sqlmap configuration file of ibatisSelectkeyElement hasTypeAttribute, which can be specifiedPreOrPostIndicates that (Pre) Or generate later (Post).
Oracle settingsXML Code
Id = "insertproduct-Oracle" parameterclass = "com. domain. Product">
Resultclass = "int" keyproperty = "ID" type = "pre">
Ms SQL Server ConfigurationXML Code
Id = "insertproduct-MS-
Tags: des blog http io ar os sp div onOriginal: Deletes all indexes of the specified table, including primary key index, unique index, and normal index, for SQL Server 2005,--Delete all indexes in the specified table--usage: DECLARE @tableName varchar--set @tableName = ' table name '-The table name, replacing--exec Sp_dropindex according to the actual situation @
(select Top 5 code from Renyuan)Select top 5*from Renyuan where code not in (select Top ten code from Renyuan) --a total of a few pagesSelect CEILING (COUNT (*)/5.0) from Renyuan --Find out all information about people older than 35 years in the sales department SELECT * from Renyuan where code in(select code from Renyuan where age>35 and ygbm=(select Bmcode from bumen where bmname= ' sales Department ')) --View all personnel information and replace the department number with the department nam
--CREATE database Db_std_mgr_sys; UseDb_std_mgr_sys;Create TableStudent (std_idbigint not NULLAuto_increment,std_namevarchar(Ten) not NULL default "', Std_codevarchar( -) not NULL default "'Comment'study number, the value is unique', Std_sexvarchar(8) not NULL default "', Std_phonevarchar( -) not NULL default "', school_idbigint not NULL default -1Comment'Your School ID', grade_idBIGINT not NULL default -1Comment'your Grade ID', cls_idbigint not NULL default -1Comment'Your class ID',
In the development process, we will use some initialization statements, because of the foreign key relationship, we need to write some ID to die, then when we are initialized, we need to increment the table in MySQL from a certain value of the primary key.ALTER TABLE ' system_role_menu ' auto_increment = 11;The table above indicates that the System_role_menu table increments from 11 and the next inserted va
After inserting a record, you want to immediately obtain the primary key return value in the data table. This primary key is automatically generated. In fact, there are many implementation methods, such as performing another query and obtaining it. Alternatively, you can obtain the maximum value before inserting data,
After inserting a record, you want to immediately obtain the primary key return value in the data table. This primary key is automatically generated. In fact, there are many implementation methods, such as performing another query and obtaining it. You can also extract the maximum value before inserting data and add on
In SQL SERVER if we want to make the primary key grow automatically according to certain rules we can do this:
Here we have a new research table with research IDs, names of researchers and research hospitals.
We set the SICENTIFICID as the primary key and start at 1 each
Tags: ted use _id value gen ATI Save key lastMyBatis getting the self-increment primary key when inserting Method has two Method 1: Insert into person (NAME,PSWD) VALUES (#{name},#{pswd}) Method 2: Select LAST_INSERT_ID ()Insert into person (NAME,PSWD) VALUES (#{name},#{pswd}) The entity id attribute before insertion is 0; The entity id attribute after insertio
Tags: mat and products Type way query data str whereMode 1: Select b.column_name
from information_schema.table_constraints a
inner join information_schema.constraint_column_usage b
= b.constraint_name
where ' PRIMARY KEY ' ' Products '
Go Mode 2: SELECT A.name
From syscolumns a
inner joins sysobjects d on a.id=d.id
where d.name= 'products'1where xtype='PK' And in (the
SELECT
artificially damage the database. The second is that two external keys can be used as the primary key in the connection table describing multiple-to-multiple relationships. I also oppose this approach because: composite primary keys often lead to bad Foreign keys. That is, when the connected table becomes another master table of the slave table, it becomes part
Sets whether to use the Getgenereatedkeys method of JDBC to get the primary key and assign a value to the domain model property of the Keyproperty setting. MySQL and SQL Server execute auto-generated key field, so when the database is set to self-grow primary
SQL statement query the table name/column name/primary key/automatic Growth Value in the database---- Query tables created by users in the database---- Jsj01 indicates the database name.Select name tablename from jsj01.. sysobjects where type = 'U' and name not in ('dtproperties ')-- Query the field information in the table--- Docs: Table Name---- Select * from s
1. ORACLE uses SELECT seq_id.nextval from dual (seq_id the sequence name corresponding to the primary key)2, DB2 use VALUES identity_val_local ()3. MYSQL using SELECT last_insert_id ()4. SQL Server uses SELECT scope_identity ()5. DERBY use VALUES identity_val_local ()6. HSQLDB using the call IDENTITY ()7. SYBASE uses SELECT @ @IDENTITY ()8, DB2_MF use SELECT iden
Do not specify an order by in SQL, sort by the primary key? The answer is not necessarily. As an example:
Query Attendanceemprank table, primary key is Attendanceemployeerankid, and is clustered index
Execute the following statement and find that the first sentence does
Tags: style blog color ar div log sp on ad--Delete primary KeyDeclare @Pk VarChar( -);Select @Pk=Name fromsysobjectswhereParent_obj=object_id('Swtoolsupdaterecord') andXtype='PK';if @Pk is not NULLexec('Alter table Swtoolsupdaterecord Drop'+ @Pk)--Reset PRIMARY KeyALTER TableSwtoolsupdaterecordADD CONSTRAINTPknamePRIMARY KEY(ID)--view current
Create a role tableCREATE TABLE Nbctxp. Tbl_nbc_nonbankrole (ID BIGINT not NULL,ROLENAME VARCHAR (50),Createtime TIMESTAMP,UpdateTime TIMESTAMP,CONSTRAINT p_id PRIMARY KEY (ID));CREATE INDEX SQL150130091455900 on NBCTXP. Tbl_nbc_nonbankrole (ID);Let the primary key increment by 1Alter table Nbctxp. Tbl_nbc_nonbankrole
Label:Sometimes to get the table primary key field, although the system from the stored procedure can be obtained, but for familiar with the system table, it is easy to write yourself.2 Declare @table_name varchar
3 Set @table_name = ' Table_pqs '
4 --1, according to system stored procedure
5 Execute Sp_pkeys @table_name
6
7 --2, obtained
8 Declare @objectid int
9 Set @
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.