I have a problem when I am trying to create a new table in phpmyadmin in a database. The code is:
DROP TABLE IF EXISTS phpcrawler_links;
CREATE TABLE phpcrawler_links (
id int(11) NOT NULL auto_increment,
site_id int(11) NOT NULL default 0,
depth int(11) NOT NULL default 0,
url text NOT NULL,
url_title text,
url_md5 varchar(255) NOT NULL,
content text NOT NULL,
content_md5 varchar(255) NOT NULL,
last_crawled datetime,
crawl_now int(11) NOT NULL default 1,
PRIMARY KEY (id),
KEY idx_site_id(site_id),
KEY idx_url (url(255)),
KEY idx_content_md5(content_md5),
FULLTEXT ft_content(content),
KEY idx_last_crawled(last_crawled)
);
DROP TABLE IF EXISTS words;
CREATE TABLE words (
id int(11) NOT NULL,
word varchar(255) NOT NULL
);
The problem seems to be on this line:
last_crawled datetime,
The error I get is:
#1214 - The used table type doesn't support FULLTEXT indexes
If anyone can help me out with this I will be greatfull!
Google rules!
Only MyISAM tables support fulltext indicies.
http://forums.mysql.com/read.php?107,194405,194677
you cannot add index to that DB if the table is Innodb, you must change the engine to MyISAM or change the data type to int
seems you are using an old version of MySQL, as from MySQL 5.6, InnoDB support fulltext index already.
Related
please give me recommendation my query does not working
SQL query:
CREATE TABLE `amenities` (
`amenities_id` int(11) NOT NULL auto_increment,
`pic` varchar(100) NOT NULL,
`des` text NOT NULL,
PRIMARY KEY (`amenities_id`)
) TYPE=MariaDB AUTO_INCREMENT=13
MySQL said: Documentation
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'TYPE=MariaDB AUTO_INCREMENT=13' at line 6
There is no type table option, you possibly want to define the table engine
and there is no mariadb engine try
CREATE TABLE amenities ( amenities_id int(11) NOT NULL auto_increment,
pic varchar(100) NOT NULL, des text NOT NULL, PRIMARY KEY (amenities_id) )
AUTO_INCREMENT=13,
engine=innodb
Or leave out the engine option if you want to default the table to the database engine/
Hope this works.
CREATE TABLE amenities (
amenities_id int(11) NOT NULL auto_increment,
pic varchar(100) NOT NULL,
des text NOT NULL,
PRIMARY KEY (amenities_id)
) AUTO_INCREMENT=13
The TYPE keyword was replaced by ENGINE long ago.
The ENGINEs are InnoDB, MyISAM, MEMORY, ARIA and possibly others. Not MySQL, nor MariaDB.
The error message ... near 'TYPE ... points exactly at or after the offending syntax: TYPE in this case. (Not AUTO_INCREMENT, which was later)
AUTO_INCREMENT=13 is produced by SHOW CREATE TABLE for possible reloading. However, it is rarely useful otherwise. It is also mostly harmless.
DROP TABLE IF EXISTS `amenities`;
CREATE TABLE `amenities` (
`amenities_id` int(11) NOT NULL AUTO_INCREMENT,
`pic` varchar(100) NOT NULL,
`des` text,
PRIMARY KEY (`amenities_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Create new Table amenities where amenities_id is a PRIMARY KEY that will be auto increment. another table field pic is a varchar data type and des is a text data type that is used for rich text.
Sorry if this is an easy question, I am coming to MySQL from SQL Server.
When I execute my create statement it contains nvarchar but commits to the database as varchar. Even in my alter statement afterwards the column does not change at all. Does the collation or DB engine make a difference?
During execution I am not encountering any issues in results, other than the fact the column changes datatype. I attached a screencast of my activity http://screencast.com/t/wc94oei2
I have not been able to find anyone with similar issues through my Google searches
Did you mean, this..
CREATE TABLE stars (
idstars int(11) NOT NULL AUTO_INCREMENT,
Name nvarchar(200) DEFAULT NULL,
PRIMARY KEY (idstars),
UNIQUE KEY Name_UNIQUE (Name)
)
----turns to---
CREATE TABLE stars (
idstars int(11) NOT NULL AUTO_INCREMENT,
Name varchar(200) DEFAULT NULL,
PRIMARY KEY (idstars),
UNIQUE KEY Name_UNIQUE (Name)
)
I've read heaps of posts here on stackoverflow, blog posts, tutorials and more, but I still fail to resolve a rather nasty performance issue with my MySQL db. Keep in mind that I'm a novice when it comes to large MySQL databases.
I have a table with approx. 11.000.000 rows (will increase to say 20.000.000 or more). Here's the layout:
CREATE TABLE `myTable` (
`intcol1` int(11) DEFAULT NULL,
`charcol1` char(25) DEFAULT NULL,
`intcol2` int(11) DEFAULT NULL,
`charcol2` char(50) DEFAULT NULL,
`charcol3` char(50) DEFAULT NULL,
`charcol4` char(50) DEFAULT NULL,
`intcol3` int(11) DEFAULT NULL,
`charcol5` char(50) DEFAULT NULL,
`intcol4` int(20) DEFAULT NULL,
`intcol5` int(20) DEFAULT NULL,
`intcol6` int(20) DEFAULT NULL,
`intcol7` int(11) DEFAULT NULL,
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
FULLTEXT KEY `idx` (`charcol2`,`charcol3`)
) ENGINE=MyISAM AUTO_INCREMENT=11665231 DEFAULT CHARSET=latin1;
A select statement like
SELECT * from myTable where charchol2='bogus' AND charcol3='bogus2';
takes 25 seconds or so to execute. That's too slow, and will be even slower as the table grows.
The table will not have any inserts or updates at all (so to speak), and will be primarily used for outputting searches on the char-columns.
I've tried to make indexing work (playing around with FULLTEXT, as you can see), but it seems that I'm missing something. Any takes on how to speed up the performance?
Please note: Im currently running MySQL on my Macbook Air (1.7 GHz i5, 4GB RAM). If this is the only answer to my performance issues, I'll move the database to something appropriate ;-)
EDIT: Explain table
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE myTable ALL NULL NULL NULL NULL 11596725 Using where
You don't need to create FULLTEXT indexes for such requests, where equality operator is used. Just create an index on every char field, that will be used in WHERE condition, and remove the fulltext index:
DROP INDEX idx;
ALTER TABLE myTable ADD INDEX charchol_idx (charchol2, charchol3);
I have a table with 3 million rows and 6 columns. The problem is that my mysqld server wouldn't generate the output for any query and it would simply time out.
I then read here that over-indexing could involve too much of swapping data from memory to disk and can cause the server to slow down.
So I ran a query ALTER TABLE <Tbl_name> DROP INDEX <Index_name>;. This query has been running for 10 hours and has not completed yet.
Is this expected to run for so long?
Is there a better way to Dropping/Altering my indices?
edit - Added SHOW CREATE TABLE output
| Sample | CREATE TABLE `sample` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`FiMD5` varchar(32) NOT NULL,
`NoMD5` varchar(32) NOT NULL,
`SeMD5` varchar(32) NOT NULL,
`SeesMD5` varchar(32) NOT NULL,
`ImMD5` varchar(32) NOT NULL,
`Ovlay` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`ID`),
KEY `FiMD5_3` (`FiMD5`),
KEY `ID` (`ID`),
KEY `ID_2` (`ID`),
KEY `pIndex` (`FiMD5`),
KEY `FiMD5_` (`FiMD5`,`NoMD5`)
) ENGINE=InnoDB AUTO_INCREMENT=3073630 DEFAULT CHARSET=latin1 |
Perhaps do the following would be faster:
SELECT ... INTO OUTFILE first
Use TRUNCATE TABLE to delete everything
Modify the table
Use LOAD to restore the data
If step 2 takes too long, perhaps dropping the table and recreate it.
I am working with mysql .
I have checked the CREATE table statement , and I saw there a KEY word
| pickupspc | CREATE TABLE `pickupspc` (
`McId` int(11) NOT NULL,
`Slot` int(11) NOT NULL,
`FromTime` datetime NOT NULL,
`ToTime` datetime NOT NULL,
`Head` int(11) NOT NULL,
`Nozzle` int(11) DEFAULT NULL,
`FeederID` int(11) DEFAULT NULL,
`CompName` varchar(64) DEFAULT NULL,
`CompID` varchar(32) DEFAULT NULL,
`PickUps` int(11) DEFAULT NULL,
`Errors` int(11) DEFAULT NULL,
`ErrorCode` varchar(32) DEFAULT NULL,
KEY `ndx_PickupSPC` (`McId`,`Slot`,`FromTime`,`ToTime`,`Head`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
But what is the meaning of it ?
It's not like a PRIMARY KEY right ?
Thanks .
It is simply a synonym for INDEX. It creates an index with the name ndx_PickupSPC on the columns specified in parenthesis.
See the CREATE TABLE syntax for more information.
It's just a non-unique index. From the manual
KEY is normally a synonym for INDEX. The key attribute PRIMARY KEY can
also be specified as just KEY when given in a column definition. This
was implemented for compatibility with other database systems.
Key and index are the same. The word Key in the table creation is used to create an index, which enables faster performance.
In the above code, Key ndx_PickupSPC means that it is creating an index by the name ndx_PickupSPC on the columns mentioned in parenthesis.
It's an INDEX on the table. Indexes enable fast lookups for specific queries which check the values of the columns the index is built on. The example uses a compound key.
They are a bit similar to the indexes you find at the end of the books. You can quickly find an entry with the index without searching through the whole book. Databases typically use B-Trees for indexes.