instagram

Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Tuesday, February 15, 2011

mysql command..

upload table to existing database inside server ..table name is earning, database is democrm
mysql -u root -p democrm < /home/synnet/earning.sql

upload a database to target server..database name is democrm
mysql -u root -p < /home/synnet/democrm.sql

dump or backap database inside server..database name is democrm
mysqldump -u root -p democrm > /home/synnet/democrm_backup.sql

dump or backup just a certain table in da database..table name is invoice inside database democrm
mysqldump -u root -p democrm invoice > /home/synnet/invoice_backup.sql

backup all database inside server
mysqldump -u root -p --all-databases > /home/synnet/alldbase_backup.sql

restore database..database name is democrm
mysql -u root -p democrm < /home/democrm/democrm_backup.sql

to restore a database that already exists..
mysqlimport -u root -p democrm democrm_backup.sql


reference : http://www.webcheatsheet.com/SQL/mysql_backup_restore.php

Wednesday, February 9, 2011

SQL Alter Column Name

user_table

+--------+----------+-----------+
| user_id| username | fullName  |
+--------+----------+-----------+
| 1      | shakira  | shakirah  |
| 2      | calvin   |calvin ang |
| 3      | sunny    | sunny loi |
| 4      | emily    | emily kong|
| 5      | shah     | mohd shah |
+--------+----------+-----------+

Syntax
The ALTER  table statement in SQL is used to modify the table 'user_table' and change keyword change the name of field to new  name of field. The syntax used for Alter Table is given below:

Alter table table_name change old_column_name  new_column_name type size

Query
The Alter Table alter the table 'user_table'. The change keyword change the column name of  user_id to id in table 'user_table'.

Alter table user_table change user_id id varchar(10)

user_table

+--------+----------+-----------+
| id     | username | fullName  |
+--------+----------+-----------+
| 1      | shakira  | shakirah  |
| 2      | calvin   |calvin ang |
| 3      | sunny    | sunny loi |
| 4      | emily    | emily kong|
| 5      | shah     | mohd shah |
+--------+----------+-----------+

** sumber : http://www.roseindia.net/sql/sql-alter-column-name.shtml

LinkWithin

Related Posts Plugin for WordPress, Blogger...