Professional Documents
Culture Documents
By this, we mean that either the entire transaction takes place at once or doesn’t happen at all.
There is no midway i.e. transactions do not occur partially. Each transaction is considered as one
unit and either runs to completion or is not executed at all. It involves following two operations.
—Abort: If a transaction aborts, changes made to database are not visible.
—Commit: If a transaction commits, changes made are visible.
Atomicity is also known as the ‘All or nothing rule’.
Consider the following transaction T consisting of T1 and T2: Transfer of 100 from account X to
account Y.
If the transaction fails after completion of T1 but before completion of T2.( say,
after write(X) but before write(Y)), then amount has been deducted from X but not added to Y.
This results in an inconsistent database state. Therefore, the transaction must be executed in
entirety in order to ensure correctness of database state.
Consistency
This means that integrity constraints must be maintained so that the database is consistent before
and after the transaction. It refers to correctness of a database. Referring to the example above,
The total amount before and after the transaction must be maintained.
Total before T occurs = 500 + 200 = 700.
Total after T occurs = 400 + 300 = 700.
Therefore, database is consistent. Inconsistency occurs in case T1 completes but T2 fails. As a
result T is incomplete.
Isolation
This property ensures that multiple transactions can occur concurrently without leading to
inconsistency of database state. Transactions occur independently without interference. Changes
occurring in a particular transaction will not be visible to any other transaction until that
particular change in that transaction is written to memory or has been committed. This property
ensures that the execution of transactions concurrently will result in a state that is equivalent to a
state achieved these were executed serially in some order.
Let X= 500, Y = 500.
Consider two transactions T and T”.
Suppose T has been executed till Read (Y) and then T’’ starts. As a result , interleaving of
operations takes place due to which T’’ reads correct value of X but incorrect value of Y and sum
computed by
T’’: (X+Y = 50, 000+500=50, 500)
is thus not consistent with the sum at end of transaction:
T: (X+Y = 50, 000 + 450 = 50, 450).
This results in database inconsistency, due to a loss of 50 units. Hence, transactions must take
place in isolation and changes should be visible only after a they have been made to the main
memory.
Durability:
This property ensures that once the transaction has completed execution, the updates and
modifications to the database are stored in and written to disk and they persist even is system
failure occurs. These updates now become permanent and are stored in a non-volatile memory.
The effects of the transaction, thus, are never lost.
The ACID properties, in totality, provide a mechanism to ensure correctness and consistency of a
database in a way such that each transaction is a group of operations that acts a single unit,
produces consistent results, acts in isolation from other operations and updates that it makes are
durably stored.
This article is contributed by Avneet Kaur. If you like GeeksforGeeks and would like to
contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to
contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and
help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information
about the topic discussed above.
A conformed dimension is a dimension that has exactly the same meaning and content when being
referred from different fact tables. A conformed dimension can refer to multiple tables in multiple data
marts within the same organization.
cd command in Linux/Unix
cd is a Linux command to change the directory/folder of the terminal's shell.
You can press the tab button in order to auto complete the directory name.
cd syntax
cd examples
cd syntax
$ cd [directory]
cd command examples
Change to home directory (determined by $HOME environment variable):
$ cd
See also
cat command
cp command
gcc command
ls
CD Command Examples
1. Write a unix/linux cd command to change to home directory?
Just simply type cd command on the unix terminal and then press the enter key. This will
change your directory to home directory.
> pwd
/usr/local/bin
Now i am in the /usr/local/bin directory. After typing the cd command and unix window,
you will go to your home directory.
> cd
> pwd
/home/matt
Here pwd command displays the present working directory.
The cd .. changes the directory to its parent directory by going back one level. The
space between the cd and .. is must.
> pwd
/var/tmp
> cd ..
> pwd
/var
3. Write a unix/linux cd command to go back to two directories?
The cd ../../ takes you back to two directories. You can extend this cd command to go
back to n number of directories.
> pwd
/usr/local/bin
> cd ../../
> pwd
/usr
4. Write a unix/linux cd command to change the directory using the absolute path?
In case of changing directory using absolute path you have to specify the full directory
path. Absolute path directories always start with a slash (/). An example is changing your
directory to /usr/bin from your home directory.
> cd /usr/bin
5. Write a unix/linux cd command to change the directory using the relative path?
In relative path, you have to specify the directory path relative to your current directory.
For example, you are in /var/tmp directory and you want to go to /var/lib directory, then
you can use the relative path.
> pwd
/var/tmp
> cd ../lib
> pwd
/var/lib
Here the cd ../lib, first takes you to the parent directory which is /var and then changes
the directory to the lib.
> pwd
/home/matt/documents
> cd /home/matt/backup
>pwd
/home/matt/backup
> cd -
> pwd
/home/matt/documents
No comments:
Po
cp command syntax
Copy from source to dest
$ cp [options] source dest
cp command options
cp command main options:
option description
cp -
archive files
a
cp -
force copy by removing the destination file if needed
f
cp -
interactive - ask before overwrite
i
cp -
link files instead of copy
l
cp -
follow symbolic links
L
cp -
no file overwrite
n
cp -
recursive copy (including hidden files)
R
cp -
update - copy when source is newer than dest
u
cp -
verbose - print informative messages
v
cp command examples
Copy single file main.c to destination directory bak:
$ cp main.c bak
Copy 2 files main.c and def.h to destination absolute path directory /home/usr/rapid/ :
$ cp main.c def.h /home/usr/rapid/
Copy all C files in current directory to subdirectory bak :
$ cp *.c bak
Update all files in current directory - copy only newer files to destination directory bak:
$ cp -u * bak
cp code generator
Select cp options and press the Generate Code button:
Options
Above command returns the number of characters in README.txt file.
Above command returns the number of characters in README.txt file.
mv old name new name Move/rename and old name to the new name
In [-s] old name new name Creates soft link on old name
Output :
Here the “s” specifies the substitution operation. The “/” are delimiters. The “unix” is the search pattern and the “linux” is the replacement string.
By default, the sed command replaces the first occurrence of the pattern in each line and it won’t replace the second, third…occurrence in the line.
3. Replacing the nth occurrence of a pattern in a line : Use the /1, /2 etc flags to replace the first, second occurrence of a pattern in a line.
The below command replaces the second occurrence of the word “unix” with “linux” in a line.
4. $sed 's/unix/linux/2' geekfile.txt
Output:
unix is great os. linux is opensource. unix is free os.
5. Replacing all the occurrence of the pattern in a line : The substitute flag /g (global replacement) specifies the sed command to replace all
the occurrences of the string in the line.
6. $sed 's/unix/linux/g' geekfile.txt
Output :
linux is great os. linux is opensource. linux is free os.
7. Replacing from nth occurrence to all occurrences in a line : Use the combination of /1, /2 etc and /g to replace all the patterns from the
nth occurrence of a pattern in a line. The following sed command replaces the third, fourth, fifth… “unix” word with “linux” word in a line.
8. $sed 's/unix/linux/3g' geekfile.txt
Output:
unix is great os. unix is opensource. linux is free os.
learn operating system.
unix linux which one you choose.
unix is easy to learn.unix is a multiuser os.Learn linux .linux is a powerful.
9. Parenthesize first character of each word : This sed example prints the first character of every word in paranthesis.
10. $ echo "Welcome To The Geek Stuff" | sed 's/\(\b[A-Z]\)/\(\1\)/g'
Output:
11. Replacing string on a specific line number : You can restrict the sed command to replace the string on a specific line number. An example
is
12. $sed '3 s/unix/linux/' geekfile.txt
Output:
unix is great os. unix is opensource. unix is free os.
learn operating system.
linux linux which one you choose.
unix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
The above sed command replaces the string only on the third line.
13. Duplicating the replaced line with /p flag : The /p print flag prints the replaced line twice on the terminal. If a line does not have the search
pattern and is not replaced, then the /p prints that line only once.
14. $sed 's/unix/linux/p' geekfile.txt
Output:
linux is great os. unix is opensource. unix is free os.
15. Printing only the replaced lines : Use the -n option along with the /p print flag to display only the replaced lines. Here the -n option
suppresses the duplicate rows generated by the /p flag and prints the replaced lines only one time.
16. $sed -n 's/unix/linux/p' geekfile.txt
Output:
linux is great os. unix is opensource. unix is free os.
linux linux which one you choose.
linux is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
If you use -n alone without /p, then the sed does not print anything.
17. Replacing string on a range of lines : You can specify a range of line numbers to the sed command for replacing a string.
18. $sed '1,3 s/unix/linux/' geekfile.txt
Output:
linux is great os. unix is opensource. unix is free os.
learn operating system.
linux linux which one you choose.
Here the sed command replaces the lines with range from 1 to 3. Another example is
Output:
unix is great os. unix is opensource. unix is free os.
Here $ indicates the last line in the file. So the sed command replaces the text from second line to last line in the file.
19. Deleting lines from a particular file : SED command can also be used for deleting lines from a particular file. SED command is used for
performing deletion operation without even opening the file
Examples:
1. To Delete a particular line say n in this example
20. Syntax:
21. $ sed 'nd' filename.txt
22. Example:
23. $ sed '5d' filename.txt
Syntax:
$ sed '$d' filename.txt
Syntax:
$ sed 'x,yd' filename.txt
Example:
$ sed '3,6d' filename.txt
Syntax:
$ sed 'nth,$d' filename.txt
Example:
Syntax:
Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records.
Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and
DuplicateColumn3.
DELETE
FROM MyTable
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM MyTable
GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3)
$ ls -l
-rw-r----- 1 ramesh team-dev 9275204 Jun 13 15:27 mthesaur.txt.gz
1st Character – File Type: First character specifies the type of the file.
In the example above the hyphen (-) in the 1st character indicates that this is a normal file. Following are the
possible file type options in the 1st character of the ls -l output.
Field Explanation
– normal file
d directory
s socket file
l link file
Field 1 – File Permissions: Next 9 character specifies the files permission. Each 3 characters refers to the read,
write, execute permissions for user, group and world In this example, -rw-r—– indicates read-write permission for
user, read permission for group, and no permission for others.
Field 2 – Number of links: Second field specifies the number of links for that file. In this example, 1 indicates
only one link to this file.
Field 3 – Owner: Third field specifies owner of the file. In this example, this file is owned by username ‘ramesh’.
Field 4 – Group: Fourth field specifies the group of the file. In this example, this file belongs to ”team-dev’
group.
Field 5 – Size: Fifth field specifies the size of file. In this example, ‘9275204’ indicates the file size.
Field 6 – Last modified date & time: Sixth field specifies the date and time of the last modification of the file.
In this example, ‘Jun 13 15:27’ specifies the last modification time of the file.
Field 7 – File name: The last field is the name of the file. In this example, the file name is mthesaur.txt.gz.
$ ls -l /etc
total 3344
$ ls -lt
total 76
drwxrwxrwt 14 root root 4096 Jun 22 07:36 tmp
drwxr-xr-x 121 root root 4096 Jun 22 07:05 etc
drwxr-xr-x 13 root root 13780 Jun 22 07:04 dev
drwxr-xr-x 13 root root 4096 Jun 20 23:12 root
drwxr-xr-x 12 root root 4096 Jun 18 08:31 home
drwxr-xr-x 2 root root 4096 May 17 21:21 sbin
lrwxrwxrwx 1 root root 11 May 17 20:29 cdrom -> media/cdrom
drwx------ 2 root root 16384 May 17 20:29 lost+found
drwxr-xr-x 15 root root 4096 Jul 2 2008 var
$ ls -ltr
total 76
drwxr-xr-x 15 root root 4096 Jul 2 2008 var
drwx------ 2 root root 16384 May 17 20:29 lost+found
lrwxrwxrwx 1 root root 11 May 17 20:29 cdrom -> media/cdrom
drwxr-xr-x 2 root root 4096 May 17 21:21 sbin
drwxr-xr-x 12 root root 4096 Jun 18 08:31 home
drwxr-xr-x 13 root root 4096 Jun 20 23:12 root
drwxr-xr-x 13 root root 13780 Jun 22 07:04 dev
drwxr-xr-x 121 root root 4096 Jun 22 07:05 etc
drwxrwxrwt 14 root root 4096 Jun 22 07:36 tmp
$ ls -a
[rnatarajan@asp-dev ~]$ ls -a
. Debian-Info.txt
.. CentOS-Info.txt
.bash_history Fedora-Info.txt
.bash_logout .lftp
.bash_profile libiconv-1.11.tar.tar
.bashrc libssh2-0.12-1.2.el4.rf.i386.rpm
It will show all the files including the ‘.’ (current directory) and ‘..’ (parent directory). To show the hidden files, but not
the ‘.’ (current directory) and ‘..’ (parent directory), use option -A.
$ ls -A
Debian-Info.txt Fedora-Info.txt
CentOS-Info.txt Red-Hat-Info.txt
.bash_history SUSE-Info.txt
.bash_logout .lftp
.bash_profile libiconv-1.11.tar.tar
.bashrc libssh2-0.12-1.2.el4.rf.i386.rpm
[Note: . and .. are not displayed here]
devices profiles
$ ls -R /etc/sysconfig/networking
/etc/sysconfig/networking:
devices profiles
/etc/sysconfig/networking/devices:
/etc/sysconfig/networking/profiles:
default
/etc/sysconfig/networking/profiles/default:
To show all the files recursively, use -R option. When you do this from /, it shows all the unhidden files in the whole
file system recursively.
279695