2013-04-22

ORACLE - How to change your own password

You can execute this command (SQL Developer or command-line):


alter user USERNAME_HERE
identified by NEW_PASSWORD_HERE
replace OLD_PASSWORD_HERE
;

2013-04-20

MySQL - Random number between a given range of integers


This will generate a random number between 180 and 210.

select
floor(
180
+ (
rand()
* (210-180)
)
) as RandomBetween180and210
;

2013-03-06

TSQL - Handling multiple CTEs


with
       cte(Num) as
       (
              select 1 as Num
              union all
              select 1.2
       )
       , cte2(Num2) as
       (
              select 2 as Num2
       )
select *
from
       cte cross join cte2
;

2013-03-04

MacOSX - Booting tricks

You can use these key combinations when your computer has problems, strange booting behaviors, etc.


  • Disk checking: Command + R
  • PRAM reset: Command + Option + P + R
  • SCM reset: Shift + Control + Option + POWER BUTTON, then POWER BUTTON


2013-03-01

TSQL - String search within stored procedures


SELECT
       Name
FROM
       sys.procedures
WHERE
       OBJECT_DEFINITION(OBJECT_ID) LIKE '%RecoveryDuration%'
;

2013-02-22

Teradata - How to rename a table


rename
table DATABASE_NAME.OLD_TABLE_NAME
to DATABASE_NAME.NEW_TABLE_NAME
;

2013-02-19

TSQL - Database stuck in restoring mode

If your database seems to have gotten stuck in "(Restoring...)" mode, then simply run this.


RESTORE DATABASE [DATABASE_NAME_GOES_HERE] WITH RECOVERY;