meta data for this page
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>create database mscmbw;
use mscmbw;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### create table Trinity ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>create table Trinity(
contig_name varchar(15) primary key not null,
lenght int(10),
path varchar(10000),
sequence varchar(50000)
);</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### show all tables in your database</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>show tables;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### Check description of your table to see if it is what you wanted</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>desc Trinity;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### remove Trinity table ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>drop table Trinity;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### remove contents from Trinity table ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>Truncate table Trinity;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### remove contents from table with condition ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>delete from Trinity where length > 0;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### import data. DO NOT IMPORT TWICE…. ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>load data local infile “/home/you/Trinity.txt” into table Trinity fields terminated by '\t';</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### view contents of table ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>select * from Trinity;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>### show the first 5 entries in Trinity table ###</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>select * from Trinity limit 5;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### Display contents of column “length” in Trinity table ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>select length from Trinity;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>### select only contigs that have the lenght less than 500nt ###</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>select * from Trinity where length < 500;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### count the entries in Trinity table ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>select count(*) from Trinity;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### create CDS table with foreign keys (link to Trinity table) ####</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### Alternatively, link the tables manually in alter table, foreign key tab ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>create table Transdecoder_CDS(
contig_ID_CDS varchar(50) primary key not null,
ORF_type varchar(100),
length int,
strand varchar(5),
original_position varchar(30),
sequence varchar(50000),
contig varchar(15) not null,
foreign key (contig) references Trinity(contig_name)
);</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### Extract information from two connected tables ####</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### In this example, we want to join a table called tableABC, which has columnA, columnB, and columnC; to another called tableXYZ. ColumnA and columnX should share “identifiers” ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>select tableABC.columnA, tableABC.columnC, tableXYZ.columnZ
from tableABC, tableXYZ
where tableABC.columnA = tableXYZ.columnX
and tableABC.columnB > 10;</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>####</font><font inherit/Courier New,Courier,monospace;;#2c3e50;;inherit>Remove foreign keys from table</font><font inherit/Courier New,Courier,monospace;;#999999;;inherit>####</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### Use when trying to remove foreign keys manually causes mySQL workbench to crash ####</font>
<font inherit/Courier New,Courier,monospace;;#999999;;inherit>#### Apply to the child table , first identify which column is causing foreign key constrains with SHOW CREATE TABLE, then DROP FOREIGN KEY of said column as it appears ####</font>
<font inherit/Courier New,Courier,monospace;;inherit;;inherit>SHOW CREATE TABLE mytableXYZ;
ALTER TABLE mytableXYZ DROP FOREIGN KEY columnX;</font>