How to rename column from table

To rename a column from an existing table, run the following command:

alter table table_name change old_column_name new_column_name attribute;

example:

alter table EXAMPLE change ONE TWO varchar(25);

Comments Off on How to rename column from table Posted in MySQL

How to insert data from one table to another

To insert records from table to another, run the following command:

insert into table_name select fields1,field2…from table_name;

example:

mysql> insert into EXAMPLE select FIRST,LAST from TEST;

To insert records from table to another without duplicate, run the following command:

insert ignore into table_name select fields1,field2… from table_name;

example:

mysql> insert ignore into EXAMPLE select FIRST,LAST from TEST;

Comments Off on How to insert data from one table to another Posted in MySQL

How to copy table

To create a table from another without data, run the following command:

create table new_table_name like source_table_name;

example:

mysql> create table EXAMPLE like SOURCE;

Comments Off on How to copy table Posted in MySQL

How to get Solaris Global zone name from Local zone

pkgparam -v SUNWcsr | grep From: | grep -v fern | head -1 | cut -d ‘:’ -f5 | awk -F” ” ‘{print “Global Zone = ” $1}’

example:

root@solaris:~> pkgparam -v SUNWcsr | grep From: | grep -v fern | head -1 | cut -d ‘:’ -f5 | awk -F” ” ‘{print “Global Zone = ” $1}’
Global Zone = sol10unix
root@solaris:~>

Comments Off on How to get Solaris Global zone name from Local zone Posted in Solaris