Posts Tagged ‘table’

How to backup and restore your MySQL database or table structure to in Linux

Whenever there is a database involved, an important task that should never be neglected is backing it up. In the case of MySQL on a Linux machine, backing up consists of executing a single command.
Backing up a MySQL database can be done with one simple command:

mysqldump -h <host> -u <user> -p<password> <db_name> > backup.sql

For example if you want to backup a local database called db1 using the user user1 with password pass1 you should write:

mysqldump -h localhost -u user1 -ppass1 db1 > backup.sql

The backup.sql file contains an SQL query for creating the exact same database. Restoring such a dump-file is just a matter of one command too:

mysql -h <host> -u <user> -p<password> <db_name> < backup.sql

Following the naming from our previous example will result in the following command to restore the database:

mysql -h localhost -u user1 -ppass1 db1 < backup.sql

In the perfect environment the backup should be created by a cronjob or anacronjob.
Another useful thing that one may want to backup is the table structure. For tables whose structure is relatively often changed this can prove to be very helpful. It is done by using one simple modification of the command for backing up an entire database:

mysqldump -d -h <host> -u <user> -p<password> <db_name> > backup.sql

Did you notice the difference? It is the -d option, which specifies that data should not be dumped. Using our previous examples this will be transform to:

mysqldump -d -h localhost -u user1 -ppass1 db1 > backup.sql
VN:F [1.9.18_1163]
Rating: 6.3/10 (3 votes cast)

Choosing the right file system for your USB drive

Choosing the right file system for your USB drive can be a really tough and tedious task. Making a USB usable on all your systems can be a real pain. And when consoles get in the picture… things can get nearly impossible.

Many users don’t want to get their “hands dirty” and get familiar with file systems, which is the main reason they suffer from USB drives that don’t work on all their platforms.

According to statistics the three most common file systems are NTFS (the current Windows standard), HFS+ (the OS X standard) and (surprisingly) FAT32 (the older Windows standard). Surprisingly, modern OSs, don’t natively support other OSs file systems. Windows doesn’t recognize HFS+ drives (or treats them as unformatted), while Mac OS cannot write on an NTFS drive.

Many Linux distros natively support pretty much every file system (or it’s a matter of downloading a small package to get support).

Home consoles, on the other hand, support very few file systems and most of the time support only read operations. In order to help users choose the best file system – the one that will work on all their platforms, we’ve composed this useful table:

  Windows XP Windows 7/Windows Vista Mac OS Leopard Mac OS Lion/Mac OS Snow Leopard Ubuntu Linux PlayStation 3 Xbox 360
NTFS (Windows) Yes Yes Readonly Readonly Yes No No
FAT32 (DOS, Windows) Yes Yes Yes Yes Yes Yes Yes
exFAT (Windows) Yes Yes Yes Yes Yes (using exFAT packages) No Yes
HFS+ (Mac OS) No No Yes Yes Yes No Yes
EXT2, EXT3 (Linux) No No No No Yes No Yes

Note: The table shows native support of the OSs. There are many packages that enable the read/write support of non-native file systems. The main focus here is on native support.

Note: Although the table points FAT32 as the clear winner, it should be noted that FAT32 is old. This being the main reason to be natively supported by so many OSs. However FAT32 is not the best choice if you disk is large or you plan to store large files since FAT32 limits both the size of the volume and the size of the files stored on it.

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

How to Round a Numeric Column to a Specified Decimal Count in SQL Server 2008 R2

This tutorial will show how to round a column to a specified decimal count. This is possible with the ROUND function. The ROUND function is used to round a numeric field to the number of decimals specified. It returns a numeric value, rounded to the length or precision specified by the programmer.

Setting Up

In this tutorial we will create a table called Products with columns of Prod_Id, ProductName, Unit, and UnitPrice. Prod_Id uses a data type of int, ProductName and Unit will be of the nvarchar data type, and UnitPrice will be of the float data type. To create a table in SQL Server, we use the CREATE TABLE statement.

Create a Products table.
Prod_Id int not null,
ProductName nvarchar(30) not null,
Unit nvarchar(30) not null,
UnitPrice float not null

Now that we have a table created, we can add data into it. To do this, we use the INSERT INTO, SELECT, and UNION statements. The INSERT INTO statement specifies what table and columns to insert values into, the SELECT statement is the data being inserted into the table, and the UNION statement prevents duplicates from being inserted into the table… Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (10 votes cast)

Comparison and Logical Operators in JavaScript

Even the simplest program uses comparison and logical operators to implement its own logic. Logical and comparison operators in JavaScript are pretty much standard and provide all the functionality that is expected from a programming language. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

Using SQL SELECT INTO statement

Quite often, when managing SQL databases, we wish to create a copy of a whole table or a few columns of it. This comes handy when we want to create a backup of a table or to archive a part of a table and is done quite easy using the SELECT INTO statement.
Let’s review this with a few examples.

The syntax for copying a whole table is:
Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

Using the SQL Auto Increment field

Quite often, when creating a new SQL table, one can’t simply think of a proper column for the Primary Key. Whether it is because of the structure of the table or because you are creating it in the middle of the night, you decide to add a column containing consecutive ints. But each time you insert a new row you must be careful to use a unique int. Isn’t there an easier way? Actually there is – the SQL auto increment field. This field allows you to generate a unique number for each new row which is inserted in the table. Let’s review the syntax.

For SQL Server:
Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 10.0/10 (1 vote cast)

How to find duplicate data in a MS Excel 2007 table by using conditional formatting

When working with large MS Excel the task of finding duplicating values in a column can get very frustrating. Well lucky for all of us MS Excel 2007 has a built-in feature for highlighting duplicating values in a table.

Consider the following table:
Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

How to insert a chart in MS Word 2007

This tutorial will show you how to insert a chart in MS Word
When it comes to presenting information nothing beats a good chart. Charts are an essential tool in most business analyses and most statistic reports. We will show you how to insert and edit any chart in MS Word 2007.
To start press the Chart button located in the Illustration group in the Insert tab on the Ribbon:
Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (10 votes cast)

Using SQL Wildcards

SQL wildcards are used when searching for data in a database. They can substitute one or more characters when working with string types. They are a sort of pattern which is used to match a character string.
The SQL wildcards are:

% – substitutes zero or more characters
_ – substitutes one character
[list_of_characters] – substitutes one character from list_of_characters
[!list_of_characters] or [^list_of_characters] – substitutes one character from not in list_of_characters

All SQL wildcards are used with the LIKE operator.
Let’s review a few examples. We will use the table Person:
Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (10 votes cast)

Sort data in MS Excel tables

In a few steps I will show you how to sort data in MS Excel tables.

One of the most used features of MS Excel is, without any doubt, the sort feature. It keeps the table in a nice orderly manner and it makes it more readable.

So let’s say we have this table:

Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.2/10 (10 votes cast)