Archive for 'Database'
Exporting and Importing in Oracle: A Quick Start
I do this about twice per year and every time I have to look back at my notes to remember how. Maybe you are in the same boat. So, to save us both some trouble I’m going to blog my notes on the subject here.
exp schemaname/password@instance FILE=d:\mydump.dmp [follow instructions]
Give the file a name after FILE, [...]
Posted: September 5th, 2008 under Database.
Comments: none
Optimize all tables in a database, Part 2
Ok, not being satisfied with my first exploration of a global “do something” mysql script I asked the community for help.
The result is posted below, and here are the links that got me here.
http://www.linuxquestions.org/questions/showthread.php?p=2668261#post2668261
http://www.linuxforums.org/forum/linux-programming-scripting/85836-loop-within-loop-mysql-ops.html#post445403
Here is the final example script that optimizes (or replace optimize
with your favorite command like backup, alter table to InnoDB, etc.)
all tables [...]
Posted: July 5th, 2008 under Database.
Comments: none
Reformatting a text field in Microsoft Access to be a true date
I had a text field (DATEOLD) with values like 20030526, that were dates in YYYYMMDD.
I needed these values to exist in a true datetime field in Microsoft
Access. So I created a new field called NEWDATE of the date/time type.
Then I ran the query below to convert the numbers.
UPDATE Itec_data1
SET [NEWDATE] = format(DateSerial (left([DATEOLD],4), [...]
Posted: July 5th, 2008 under Database.
Comments: none
Selecting Date from a Mysql field in specific format
I had a membership table with users and the datetime at which they
joined the site. I needed to get a count of members joining per month,
so I did this:
SELECT DATE_FORMAT( regdate, ‘%b %Y’ )
AS
MONTH , count( uid ) AS Users
FROM gl_users
GROUP BY MONTH LIMIT 0 , 30
Which resulted in
SQL result
[...]
Posted: July 5th, 2008 under Database.
Comments: none
How to append tables in Mysql
For those of you that have puzzled over how to append tables in Mysql like an Access ‘Append’ query, start here:
insert into table1 select * from table2;<br />
Where table1 and table2 are identical. This might fail if you use an auto-incrementing counter on both.
Posted: July 5th, 2008 under Database.
Comments: none
SQL: My Oracle quick reference
SET PAGESIZE 400
SET LINESIZE 120
SPOOL C:\TEMP\FILENAME.TXT
SPOOL OFF
ED
SAVE -> ALT-F4
/
SELECT * FROM TAB
SELECT MAX(LENGTH FIELDNAME) FROM TABLE
COLUMN FIELDNAME FORMAT A25 (FOR TEXT)
Posted: July 5th, 2008 under Database.
Comments: none