ALTER TABLE YOUR_TABLE ADD (LAST_MODIFIED DATE);
CREATE OR REPLACE
TRIGGER YOUR_TABLE_BEFORE_INS_UPD BEFORE INSERT OR UPDATE
ON YOUR_TABLE
FOR EACH ROW
DECLARE CURRENT_TIME DATE;
BEGIN
CURRENT_TIME := SYSDATE;
:new.last_modified := CURRENT_TIME;
END;
Showing posts with label command line. Show all posts
Showing posts with label command line. Show all posts
Monday, September 22, 2008
Trigger to mimic MySQL "last modified" datatype in Oracle
Labels:
11g,
command line,
last modified,
mysql,
oracle,
sql,
sysadmin,
systems administration,
trigger
To start up everything Oracle
$ . oraenv
$ sqlplus “/ as sysdba”
SQL> startup
SQL> exit
$ lsnrctl
LSNRCTL> start
LSNRCTL> exit
$ cd $ORACLE_HOME/bin
./emctl start dbconsole
Labels:
11g,
command line,
oracle,
sql,
sysadmin,
systems administration
Shut down everything Oracle:
$ . oraenv
$ sqlplus “/ as sysdba”
SQL> shutdown immediate
SQL> exit
$ lsnrctl
LSNRCTL> stop
LSNRCTL> exit
$ cd $ORACLE_HOME/bin
./emctl stop dbconsole
Reversi search through the command history in bash shell
At the empty prompt, hit Ctrl + r then type something then hit Ctrl + r to step through previous commands containing that text.
piggy back port forward through intermediary box
This will take port 2222 on your local host and terminate it at 22 on ultimate_destination_host_ip via
your ssh tunnel to intermediary_host_ip
ssh -L 2222:ultimate_destination_host_ip:22 intermediary_host_ip -l username_common_to_both_hosts
Labels:
command line,
port forward,
shell,
ssh,
sysadmin,
system administration,
tunnel
find and replace recursively in all files
find ./httpdocs/template-modules/ -type f -exec sed -i 's/beta.refinery29.com/ww2.refinery29.com\//g' {} \;
here is one to replace directory paths:
find ./httpdocs/templates/ -type f -exec sed -i 's/\/var\/www\/vhosts\/refinery29.com\/subdomains\/beta\/httpdocs\//\/var\/www\/vhosts\/refinery29.com\/httpdocs\//g' {} \;
Labels:
command line,
find and replace,
regex,
regular expression,
sed
Best SVN folder structures
for a project that has no sub projects:
/path/to/repos/projectname/trunk
/path/to/repos/projectname/tags
/path/to/repos/projectname/branches
for a project with multiple sub projects:
/path/to/repos/projectname/trunk/subprojectname1
/path/to/repos/projectname/trunk/subprojectname2
I am not sure that it is completely necessary to have the subprojectname folders under both tags and branches however.
Labels:
command line,
development,
repository,
source control,
svn,
sysadmin,
system administration
creating new svn repos and adding new project
Start by using svnadmin to create the repository somwhere that make sense. Most times if your just putting it on your workstation you should just put it in your home directory. If you want other users to have access to the repository put it somewhere globally accessible like /usr/local/subversion/repos
$ svnadmin create /usr/local/subversion/repos
then once the repository has been created you will want to add your current project to it.
go into the directory that holds the files you want to put into the repository.
$ cd /path/to/project/directory
then import the files into the repository making sure to use a similar path structure like below including the projectname and trunk and possibly a subproject name if your project has multiple subprojects. If not you can omit that part.
$ svn import ./ file:///usr/local/subversion/repos/projectname/trunk/subprojectname -m 'Initial import of projectname subprojectname'
now that that has been done you still need to get a working copy of the files on your local machine so delete all the files in the current directory.
$ svn checkout file:///usr/local/subversion/repos/projectname/trunk/subprojectname -m 'Initial import of projectname subprojectname'
now you will have a copy of all of the files you imported recreated within the folder you just deleted them from but this time their versions will be tracked and you can do things like:
svn status (to check what you have changed in your working copy)
svn update (to get all new files from the repository)
svn add filename (to add new files into the repository)
svn commit (to update the repository with all the changes from your working copy)
Labels:
command line,
development,
repository,
source control,
svn,
sysadmin,
systems administration
Install and setup mysql 5 with ports
MySql 5 Server
sudo port install mysql5 +server
sudo chown -R mysql:mysql /opt/local/var/db/mysql5
sudo -u mysql /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql
ln -s /opt/local/var/run/mysql5/mysqld.sock /tmp/mysql.sock
Ruby’s gems installation
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-include=/opt/local/include/mysql5 --with-mysql-lib=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
Start MySql server
sudo -u mysql /opt/local/lib/mysql5/bin/mysqld_safe &
Stop MySql server
/opt/local/bin/mysqladmin5 -u root shutdown
It’s a good idea to create alias for you, here’s mine:
alias mysql_start='sudo -u mysql /opt/local/bin/mysqld_safe5 &'
alias mysql_stop='/opt/local/bin/mysqladmin5 -u root shutdown'
And remeber: mysql.socks lives on /opt/local/var/run/mysql5 as mysqld.socks
/opt/local/var/run/mysql5/mysqld.sock
Labels:
command line,
database,
development,
mysql,
ports,
sysadmin,
system administration
Subscribe to:
Posts (Atom)