Published on
January 10, 2009 in
Database.
I have a Oracle database table with some fields (columns) in numeric format. Now I need to update one column, namely store_id, to make it a primary column with unique number id. Since there were a lot of duplicate data in this column, the best way to do is to update this column with the sequence numbers.
To accomplish this, I need to create a sequence object in Oracle, and use Oracle cursor to loop and update the table column.
Here is the PL/SQL I used and worked.
DECLARE
Cursor store_id
IS
SELECT store_id FROM store_locations FOR UPDATE;
BEGIN
FOR c_store_id IN store_id LOOP
UPDATE cms_store_locations
SET store_id = store_seq.nextval
WHERE CURRENT OF store_id;
END LOOP;
commit;
END;
/
Related posts
Published on
December 19, 2008 in
Database.
Recently just re-installed the Microsoft Office SharePoint Server (MOSS) 2007 applications and database on new servers. But the SharePoint data files were in the C: system drive, which does not have enough space.
To move database files to the D: data drive, what I needed to do is
- Remove Content Database from the SharePoint Administrative Central.
- Deattch the database from Microsoft SQl server
- Move data files to the D: drive
- Re-attach the database
- Add Content Database to Web Application.
Related posts
Published on
September 23, 2008 in
Database.
I have tried to re-configure the old web site log analyst tools – LiveStats XSP 6.2 for a long, long time. Finally I decided to wipe all of them and re-install again. To be safe, I have to back-up all MySql data (installed by LiveStats) first. Since the server is a Windows 2000, and I could not use web interface like Phpmyadmin. Well, I can copy all *.MYD files. But I found a better way by using the the following commands came with MySQL installation.
Continue reading ‘How to export and import MySql database’
Related posts
Blog Comments