Recent Notes

Displaying keyword search results 21 - 31
Created by Dr. Xi on March 31, 2010 19:32:42    Last update: March 31, 2010 19:41:14
The dev database keeps locking up because of failed login attempts. For a dev database, we really don't need such security measure. This is how to remove the limit. Log in as sysdba sqlplus sys@xe as sysdba Find out the profile for the user. SQL> select profile from dba_users where username ... Look at the current limits SQL> select resource_name, limit from dba_profiles... Increase the value for failed login attempts SQL> alter profile default limit failed_login_atte...
Created by Dr. Xi on January 07, 2010 23:40:28    Last update: February 09, 2010 03:24:35
This is a utility to generate SQL insert statements for Oracle for one table, or a set of tables. It doesn't cover all possibilities but should be good enough for most cases. import java.io.*; import java.sql.*; import ... To generate insert statements for multiple tables, simply put the table names in a file, one per line, and use the -f switch.
Created by Dr. Xi on November 13, 2009 16:59:10    Last update: November 13, 2009 20:27:04
When you set DEBUG=True in settings.py , Django saves a copy of every SQL statement it has executed in django.db.connection.queries : >>> from django.db import connection >>> connec... You can clear the list of saved queries by calling django.db.reset_queries() : >>> from django import db >>> db.reset_queries(... Example: from django.db import models class Author(m... >>> a = Author(name='author', email='a@domain.com'... Use select_related to fetch all related objects in one query: >>> db.reset_queries() >>> e2 = Entry.objec... By default, select_related with attribute name only goes one level up: >>> db.reset_queries() >>> e2 = Entry.objects.s...
Created by Dr. Xi on March 24, 2009 23:40:51    Last update: March 24, 2009 23:41:34
The DECODE function is used to decode a key to a value , returning the default value if one is provided. It returns null if there's no match for keys and no default value is provided. select DECODE(&quarter_id, '1', 'Spring', '2',...
Created by Dr. Xi on March 08, 2009 20:42:32    Last update: March 08, 2009 20:43:17
encoding : The 'encoding' option tells Vim the encoding of the characters that you use. This applies to the text in buffers (files you are editing), registers, Vim script files, etc. For example: :set encoding=utf-8 You need to use an appropriate font to display Non-ASCII characters: X Windows: :set guifont=-misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1 Win32: :set guifont=courier_new:h12 , or select one from the Edit/Select Font... menu termencoding : Encoding used for the terminal. For the Win32 GUI 'termencoding' is not used for typed characters, because the Win32 system always passes Unicode characters. fileencoding : When you edit a file, vim tries to detect what kind of file you are editing. It uses the encoding names in the ' fileencodings ' option. When using Unicode, the default value is: "ucs-bom,utf-8,latin1"....
Created by Dr. Xi on November 07, 2008 20:52:47    Last update: November 07, 2008 20:52:47
MySql: CREATE TABLE IF NOT EXISTS MyTable ( ID int(1... SQL Server: IF NOT EXISTS ( SELECT [name] FROM sy...
Created by Dr. Xi on September 29, 2008 23:05:12    Last update: September 29, 2008 23:06:16
These variables are set or used by the Unix shell to modify its behavior. Variable Description ENV=file Name of script that gets executed at startup; Usually, ENV=$HOME/.kshrc FCEDIT=file Editor used by fc (fix command) command. If $FCEDIT is not defined, use $EDITOR, otherwise use the default (vi or ed). FPATH=dirs Directories to search for function definitions; undefined functions are set via typeset -fu . FPATH is searched when these functions are first referenced. HISTFILE=file File in which to store command history. Default is $HOME/.sh_history for Korn shell, $HOME/.bash_history for Bash. If not set, history is lost after logout. HISTSIZE=n Max number of commands to keep in history. HOME=dir Home directory; set by login from passwd file. IFS='chars' Internal field separators. Default is space, tab, and...
Created by Dr. Xi on September 29, 2008 23:03:40    Last update: September 29, 2008 23:04:08
Variables set automatically by shell: Variable Description $# Number of command-line arguments. $- Options currently in effect (arguments supplied to sh or to set). $? Exit value of last executed command. $$ Process number of current process. $! Process number of last background command. $0 First word; that is, command name. $n Individual arguments on command line (positional parameters). The Bourne shell allows only nine parameters to be referenced directly (n = 1-9); the Korn shell allows n to be greater than 9 if specified as ${n}. $* All arguments on command line ("$1 $2..."). $@ All arguments on command line, individually quoted ("$1" "$2" ...). Variables set automatically by Korn shell: Variable Description ERRNO Error number of last system call that failed. LINENO Current...
Created by Dr. Xi on September 21, 2008 21:04:24    Last update: September 21, 2008 22:27:36
IE uses Notepad as the default editor when you select "View Source" from a web page. You can change it to your favorite editor by adding a couple of keys to the registry: Start regedit Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ Add key View Source Editor Under View Source Editor , add key Editor Name Change the default string value to the full path of your favorite editor. The following is the registry entry for vim (full tip for vim is available from the vim wiki ): Windows Registry Editor Version 5.00 [HKEY_... It is probably easier (less error prone) to edit this in a file and import it back into the registry. The contents of gvim.vbs are: '--- gVim.vbs ------------------------------------... It is OK to use gvim.exe...
Created by Dr. Xi on September 07, 2008 03:04:23    Last update: September 07, 2008 03:07:22
Suppose you have a CONTACT table, one of the contacts is your primary contact (the default). You want to output a list of contacts with your default contact listed first and the rest listed alphabetically. And further assume that you have a column named is_default with values 'Y' or 'N' to indicate who is the default contact. You can use this query: SELECT last_name, first_name, phone_number FROM...
Created by Dr. Xi on September 07, 2008 02:53:31    Last update: September 07, 2008 02:57:22
A UNION query combines the result sets of several similar SELECT queries. Each SELECT statement must have the same number of output fields, in the same order, with same or compatible data types. Duplicate rows are removed from the result set. SELECT name, price, warranty_available, exclusive_... If there's not order by clause, the order of the result set is the default order of the combined result set, not the result set of the first SELECT followed by the result set of the second SELECT. You can add an order by clause to a UNION query, which will be applied to the combined result set: SELECT name, price, warranty_available, exclusive_... Using ORDER BY in each SELECT query does not make sense: -- This is invalid SELECT name, price, warranty...
Previous  1 2 3 Next