Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How To Create Index When Doing 'create Table As Select'


Code:
Create mysqlorary table mysql
AS SELECT
Name
FROM
EmployeeList
WHERE
Dept = 'XXX'

I would l ike to create an index on the field Name of the mysqlorary table mysql. I wonder if I can create the index on the fly by adding sth in the above statement.




View Complete Forum Thread with Replies

Related Forum Messages:
If I Create An Index With Multiple Fields Do I Still Need To Create Individual Ones?
I have a table where the name field can only contain duplicates when the user_id field is different, so I create an index with user_id,name. Now I was wondering if I want to search just for the user_id or the name field individually does this dual field index count, or should I create another index for the user_id and the name?

View Replies !
Create Index For A Mysqlorary Table
I have to do SQL query over two mysqlorary tables, I want to create indexes on fields of the mysqlorary tables.

Is it possible to create index on a mysqlorary table. I am using MySQl 5.0.26

Furthermore, Is it possible to merge the statements for creating mysqlorary table and the statement for creating index on the mysqlorary table into one singel statement....

View Replies !
CREATE TABLE AS SELECT
I'm trying to write a bit of code that I can use to create development copies of databases and specific tables.I've made a number of script that can do what I'm after apart from one small problem.. the development server uses it's own installation of mysql.I've able to re-create databases and tables on the same server easy enough using..

CREATE TABLE AS SELECT*

and

SELECT * INTO OUTFILE

but for the life of me I can't think of away to transfer the tables structure from server to server.

View Replies !
Create Table Select
I've been doing some googling and searching the forums but I'm not finding any clear explainations of what I want.
I need to keep a daily backup (1 for each day of the week) of a table and I'm not sure of the best way to do it and keep the information as easily accessable for use as possible. There would be 6 tables that I would want to routinely "truncate" and then fill with the data from the current day. That would give me 7 days worth all the time but only the current days table being written to.
That said, maybe it's even best to dump the table to an XML file and keep it that way instead of using a backup table for each day. I'm just not sure what's going to be the most efficent for both the server/db overhead and ease of grabbing and parsing the data for use.I'm hoping a few of you guys have needed to do stuff like this and can give me some suggestions for the best way to accomplish this.

View Replies !
Create Table From Select
I have a query that need to put all data on this new table, the thing is that every day these table must be empty or delete and create the new table again

SELECT T.time, T.name, T.last, P.company, P.wife FROM T INNER JOIN P ON T.wife = P.wife and T.company = P.company INTO newtable

View Replies !
CREATE TABLE, INSERT INTO With SELECT In Parentheses
Assuming a legal SELECT statement, this works fine:

CREATE TABLE Foo SELECT ...

but this does not:

CREATE TABLE Foo (SELECT ...)

This is a problem for me as I'd like to use the output of a
SELECT...UNION...ORDER BY statement as input to CREATE TABLE.

Same holds for INSERT INTO.

Is this a bug?

View Replies !
Create Another Field After Create Table
i have create a table from CLI, i would like to add another field after create table.
How to do that ?

View Replies !
Rights To Create Table, Select, Then Drop Table..
I have a need to get data from the db that requires me to=20

1) do a select and create a new table with the results=20
2) run a query against that new table=20
3) drop the new table=20

I have a script on my server that does this using the root account that has all on *.* for the db. It works fine.=20

I now want to get these results on a web page.=20 I want to create a new db user for my .php web page to use to connect to the db that only has the needed priviledges on that specific db to get the job done.=20

what priviledges do I need to give that user?=20

currently I have the following but the user can't even log into the db from the command line..=20

mysql> show grants for user;=20
+-----------------------------------------------------------------------
---------+=20
| Grants for user@% |=20
+-----------------------------------------------------------------------
---------+=20
| GRANT USAGE ON *.* TO 'user'@'%' IDENTIFIED BY PASSWORD
'6fe4c0ab2cf30ae3' |=20
| GRANT SELECT, INSERT, UPDATE, CREATE, DROP ON `db1`.* TO 'user'@'%' |=20
+-----------------------------------------------------------------------
---------+=20
2 rows in set (0.00 sec)=20

when I do a "show grants for user", what should I see to allow what I want?

View Replies !
UDF In Create Index
Is it possible to use function UDF in CREATE INDEX declaration ?

For example: CREATE INDEX innertext ON webpages (MY_UDF(html)).

It's avoid the creation of an intermediate column with the data transformed.

View Replies !
Create Index
On an Oracle database it is possible to create an index for a table on a different tablespace.
(create index userindex on user (userid) tablespace indices;)
I did not found a similar statement in the MySQL Reference. Is there another way to do that?

View Replies !
Create The Effective Index
I want to create the best index for that query:

"select * from talkback where status=0 order by bject_type,vertical_id,event_id"

Which index i need to create for best performance.

View Replies !
Can't Create Index ... 1044
My user wood@localhost can't create an index on the databse woodwork... I
get the error

ERROR 1044: Access denied for user: 'wood@localhost' to database 'woodwork'

mysql.user reads...

+----------------+------------+
| user | index_priv |
+----------------+------------+
| root | Y |
| root | Y |
| | N |
| | N |
| wood@localhost | Y |
+----------------+------------+

anyone know why?

View Replies !
Create An Index Without Using All Available Connections
I've got a very large table (149 fields -- I know, I didn't create it, and I'm working on changing it...) and I need to add an index to speed up a join query.
However, when I run the "create index `index_name` on table(`column`)", MySQL uses every available connection to attempt the creation of the index, and does not allow the web site to access the database.
If this was a short period of time (a couple of minutes), I could stand it. unfortunately, this is a live production server, and I'm guessing it will take an hour or two to create the index.
Does anyone know how I can run the "create index" query while limiting the number of connections the query uses?

The version is: mysql Ver 12.22 Distrib 4.0.16, and "max_connections" is currently set to 100.

View Replies !
Killing An Index Create
I am running a create index on a large table. The job is taking an extremely long time. If I kill the create index process what are the ramifications in MySQL? Will it simply roll back the index? And is there any way to see a percentage remaining on the job?

View Replies !
Create Index On Date Field
I have a table:

+-------------+--------------------------+------+-----+---------+-------
---------+
| Field | Type | Null | Key | Default | Extra
|
+-------------+--------------------------+------+-----+---------+-------
---------+
| id | int(11) | | PRI | NULL |
auto_increment |
| NUMFATT | int(5) unsigned zerofill | | | 00000 |
|
| dataemiss | date | YES | | NULL |
|
+-------------+--------------------------+------+-----+---------+-------
---------+
(the table has more fields but I removed them to semplify the view of
it). Where I want to create a UNIQUE index with two tables 'dataemiss' and 'NUMFATT'
'dataemiss' is a date format and in the index I want to consider just the year part of the date.
I cannot change the field type setting it as a string (ex. char, var, etc.). any hint on how to do it?
The goal of this is index is to avoid to insert the same 'NUMFATT' twice
or more in the same year. I'm using MySQL 4.0.13 on Win 2K server.

View Replies !
Create Index And Bookmark Script
I am using a bookmark script and have created a few sites with it.Sites run great when DB is small but the large site (190 MB) DB is hogging CPU I have been kicked out of two host for this last host suggested I create index on DB this is what the tables look like
bookmarks table 189,134 rows
bId uId bIp bStatus bDatetime bModified bTitle bAddress bDescription bHash
Bid Bookmark Id is PRIMARY ties to tags table
Tags this is probably where indexing would help the most as the google bots try and index the whole site all at once and kill the host
Tags table 1,451,202 rows
id bId tag
id Primary key
bId bookmark Id

View Replies !
Create Index Takes More Than 5 Hours
I'm running MYSQL on a windows xp laptop with an intel centrino 1.60 GHz Processor and 512MB RAM. I've created a table and imported 27 million rows of data.

I wanted to create an index on one char(55) field, as this field is a key against which many selects will be made.

The information in the field is not conducive to having an integer key as any queries would require an extra join to the look-up (reference) table.

Creating the index ran for more than 5 hours and finally gave up when there was no more space on the drive (creating the index apparently consumed more space (11GB) than the actual table (8GB).

I'm wondering if this is normal time and space consumption for 27 million rows.

Finally, doing an un-indexed query on this table :

SELECT * from historical where reference = 'abcd';

Takes more than 1/2 hour. Is this also a normal amount of time?

I understand that people are using MYSQL for data warehousing and major transactional applications.

View Replies !
Create An Index Using A Substring Of A Field Value
Can something like this be done to create an index in MySQL 5?

ALTER TABLE `contact_info` ADD INDEX `idx_emailDomain`( SUBSTRING_INDEX(`Email`, '@', -1) ) ;

I've tried it and get an syntax error where I am trying to use SUBSTRING_INDEX() function.



View Replies !
How To Create/choose A Suitable Index
I am having trouble figuring out a suitable index(es) in the following case:

select * from circuit where (col1a=val1 and col2a=val2) or (col1b=val1 and col2b=val2);

(it happens that I use val1 and val2 as above).

Every choice I make for index doesn't, according to EXPLAIN, get used by the SELECT. The table has a few thousand entries and I expect the SELECT to return one or two at most. Well, it does, but quite slowly (in fact the SELECT is a bit more complex) and I would really like to improve this particular combination as its at the inner-most loop of my PHP code :-)

INDEXes seem to work for ANDs but not when there's an OR in the month (sorry). So an index of columns A,B gets used if you have A AND B in the WHERE but not A OR B.

View Replies !
CREATE INDEX Crashes Server (Lost Connection...)
I'm having trouble with a table I created quite a while ago and now want to add an index to. Here's what I get if I try to add an index on the host field of my table:

mysql> create index Index_host on uselog(host);
ERROR 2013 (HY000): Lost connection to MySQL server during query

Connection was lost because the server crashed. The Windows event log has an event that says "Faulting application mysqld-nt.exe, version 0.0.0.0, faulting module mysqld-nt.exe, version 0.0.0.0, fault address 0x0017dc06."

I've also tried the allegedly identical "ALTER TABLE uselog ADD INDEX Index_host(host)", as well as trying to index a different column, all with the same outcome (server crash).

Thing is, I had no trouble adding an index to the same table a week or so ago. The table was smaller then (and had only one index), but even now, it's not very big by DB standards, so I can't imagine that's the problem.

(My table had ~900K rows earlier today, which I pruned down to 140K rows after my first failed attempt to add the index. Puny! Only 55MB data length, according to MySQL administrator.)

View Replies !
Unable To Create Full Text Search Index On A Column
I have installed MySQL 5.0 on my WinXP machine. I have created a test schema in which I have created a test table as follows:

Test_Table
{
Id => Integer and Primary Key
Name => Char(255)
Address => Char(255)
Tags => TEXT
}

Now I want to create a full text seach index on column Tags, but when ever I try to execute following SQL statement:

ALTER TABLE `TEST_TABLE` ADD FULLTEXT `Index_FTS`(`Tags`);

I get following error:

Error while executing query:
ALTER TABLE `TEST_TABLE` ADD FULLTEXT `Index_FTS`(`Tags`);
MySQL Error Number 1283
Column 'Tags' cannot be part of FULLTEXT index.

My table is MyISAM based table.

View Replies !
How To Create Different Namespaces When Using CREATE VIEW?
I'm doing a triple join between tables which have similarly named fields...I was hoping that when using CREATE VIEW, the result would be a table with fields such as a.field, b.field, c.field...but I get an error "Duplicate column name 'field'"

...How can I get around this besides changing the name of the duplicate field in each table?

View Replies !
Does Each SELECT Statement Create A New Connection?
I've developed and currently maintain a company website which is hosted on a shared server plan. I have a modest grasp of the ins and outs of connecting to and retrieving data from mysql. However,

When a user visits our website, a connection to the database is made to retrieve the pages needed data. In this example there's one SELECT statement. So, one connection, one SELECT statement.

But, what if the biggest page on our site is written like this: ....

View Replies !
CREATE Tablename Based On Result Of SELECT Statement?
Is it possible to have an CREATE statement that contains a SELECT in the section of the CREATE that specifies the TABLE?

I want to have a sql script that can execute SELECT YEAR(CURDATE()) and SELECT MONTH(CURDATE()) to give me the Year and Month and then use these to create the Table Name: tbl_MetaData_2008-03

Example:

CREATE TABLE tbl_MetaData_X-Y
( ...

Where X is the YEAR and Y is the MONTH

View Replies !
Create MySQL Select Query From The A Field Using SUBTRING_INDEX
Is it possible to create a MySQL query to do the following.

Extract from TABLE.field, which is defined as text, containing either NULL, number (e.g. 54) or range of numbers (e.g. 70-95).

Then use the extracted number within a WHERE clause


I have looked into using something like SELECT SUBSTRING_INDEX(table.field, '-', 1);

Problem is I don't know how to use this within the WHERE clause.

View Replies !
Create Table Sql
I get error "#1005 - Can't create table './sitemanager2/test_buyers.frm' (errno: 150)

when I add the foreigh key statment, can someone tell me what is wrong with it? If I don't have that , table gets created. I ndo have a table 'test_parent_offer' with a field 'id'

CREATE TABLE `test_buyers` ( `id` bigint(20) NOT NULL auto_increment, `buyer` varchar(255) NOT NULL default '', `api_name` varchar(255) NOT NULL default '', `active` varchar(255) NOT NULL default '', `path` varchar(255) NOT NULL default '', `type` enum('url','view') NOT NULL default 'url', `offer_id` int(11) default NULL,
`parent_id` int(11) default NULL,
CONSTRAINT FOREIGN KEY (`id`) REFERENCES `test_parent_offer` (`id`) ON DELETE CASCADE,
PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1

View Replies !
Create New Table
I have a master table called 'master'. On a monthly basis, I create a new table called 'tbl_200410' (for october this year) - Once the table is created, I want to take some field out of the 'master' table and insert the data into the newly created table.
How would I do that ? The fields are named the same in both tables.

View Replies !
Cannot Create Table
I've just installed the latest stable 5.0.37 community server on my MacBook running OSX 10.4.9 with all patches up to date.
I am using MySQL Client 5.1.8 and Query Browser 1.2.11, and the standard Apache built into the OS. I am running as root on localhost as this is purely a development environment and I will tighten up security later on.
I am a standard user under OSX and installed the MySQL server and tools from this account, using an Athenticate admin login/password when prompted.
The problem comes when trying to create a table using the GUI. The following code was created using the GUI's New Table form in the `Training` schema:

CREATE TABLE `Training`.`INS_Instances` (
`INS_ID` INT NOT NULL AUTO_INCREMENT,
`INS_Description` VARCHAR,
PRIMARY KEY (`INS_ID`)
)
ENGINE = InnoDB
CHARACTER SET utf8;

Results in an SQL Syntax error. Breaking it down into a script Window, the script fails on "CREATE TABLE" (which I placed on its own on the first line) I can't see anything obviously wrong with the statement.

View Replies !
Can't Create A Table
I'm trying to install geeklog, and since I use MySQL only occasionally I'm not exactly sure what I'm doing. I've got no problem creating the database, but I'm doing something wrong with permissions, apparently. I'm using 5.0.22 on RHEL5.

mysql> show grants for current_user;
+-------------------------------------------------------------------------------
-----------------------------------------------------------+
| Grants for denman_user@localhost
|
+-------------------------------------------------------------------------------
|
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER O
N `geeklog`.`geeklog` TO 'denman_user'@'localhost' |
+-------------------------------------------------------------------------------
-----------------------------------------------------------+

mysql> use geeklog
Database changed

mysql> create table testing;
ERROR 1142 (42000): CREATE command denied to user 'denman_user'@'localhost' for
table 'testing'

View Replies !
Create Table
I have a script that creates a new table which works fine in MySQL version 5.027-standard-log
The script creates a new table named eventImpression
I recently installed MySQL version 5.1.22-rc-community
and now running my script will only produce a table with the name eventimpression
Notice how the table name no longer has the capital 'I' although the script clearly has the uppercase 'I'
Does anybody know what may be the cause of this problem?

View Replies !
Can't Create Table
SELECT r501.pat, r501.ped, r701.pedorig,r501.cveped, r506.fecha, CASE WHEN r501.rfcimp = ' '
THEN r501.crupimp
ELSE r501.rfcimp END,
r501.curpaa, r501.pesob, importe.suma, bancos_3.nombrebanco, r501.archivo from r501
inner join firmas2 on r501.ped = firmas2.pedto and r501.pat = firmas2.pat and .........

View Replies !
Create Virtual Table During Query Or Load Table To Memory From Text File
I have access to my application database via a secure link, so I cannot link a local database to it, only run queries on the remote server and download the result.

The database is missing some useful information, and I cannot add a table at this stage. I would like to achieve the result by creating a virtual table or the like. ...

View Replies !
ERROR 1005: Can't Create Table './db/table.frm' (errno: 150)
I found the key to solve this problem in:

http://darkstar.ist.utl.pt/mysql/do...onstraints.html

You'll probably need an INDEX for that new foreign key you are declaring in
older versions this isn't neccesary but in latest ones it is a restriction.

You can have more info about the error description if you have root access
by typing
mysql> show innodb status;

LATEST FOREIGN KEY ERROR
------------------------
030807 1:27:10 Error in foreign key constraint of table database/table:
There is no index in the table database/table where the columns appear
as the first columns. Constraint:
foreign key (key) references database.table(key) on delete cascade)
type=innodb

also if you type:
shell> perror 150

you obtain:
150 = Foreign key constraint is incorrectly formed

I hope this to be enough...

View Replies !
ALTER TABLE Produces Error # 1005 Can't Create Table.
I'm a SQL 2000 DBA intern

I'm replicating a current production MySQL DB into a WAMP enviornment on my computer. The production version is on a MySQL 5.0.22-Debian_0ubuntu6.06.3 and my WAMP sandbox is running MySQL 5.0.51b.

So i exported the production database to a sql file and tried using phpMyAdmin to upload it to my WAMP sandbox. MySQL on my computer gave me and error on the piece of code:

ALTER TABLE `Event_Crews` ADD CONSTRAINT `Event_Crews_ibfk_1` FOREIGN KEY ( `Event_ID` ) REFERENCES `Events` ( `Event_ID` ) ON DELETE CASCADE ON UPDATE CASCADE

where Event_ID on both tables is an int.

and I get this error from MySQL:

#1005 - Can't create table '.ambulance#sql-11d8_7d.frm' (errno: 150)

View Replies !
Could Not Connect To The Database, Please Recheck The Settings You Specified. Also Make Sure That A Database With The Name You Specified Already Exists On The Database Server. PhpAdsNew Will Not Create The Database For You, You Must Create It Manually
The error message I get above is the same everytime when trying to install phpAdsnew. I have tried everything. I am hosted through yahoo! and have actually succesfully installed scripts before even though I know nothing about it. Now that I have a "auto-install", it does not work. Yahoo! also offers php-nuke with the auto-install where you just click a few buttons, and I get a similar error stating that it can not conect to the database.

Please can anyone help me and tell me what I am doing wrong?

View Replies !
Error In CREATE TABLE
I am having error trying to run some mysql script (back from 2001). It
gives me the error like :

ERROR 1067 (42000) at line 48: Invalid default value for 'log_id'

in the statement :

CREATE TABLE Log (
log_id int(11) DEFAULT '0' NOT NULL auto_increment,
source_id smallint(6) DEFAULT '0' NOT NULL,
l_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
l_nanos int(11) DEFAULT '0' NOT NULL,
l_message text,
PRIMARY KEY (log_id)
);

What is this? I am not familiar with mysql, the script is part of
another installation script for the program made in 2001 by the
company that no longer exists. We needed to upgrade the machine the
program was running (redhat 8) to the RedHat ES 4. Now the installation
script gives us this error.

View Replies !
Create Temporary Table
When I try and run the following query

create temporary table russ1 as

select rcust.*

from rcust;

and I receive the error message:

Error Code : 1044

Access denied for user: 'russ@192.168.1.79' to database 'customer'

(0 ms taken)

I can run the query from the command line of the server and the query
works correctly.

I have run the query GRANT ALL PRIVILEGES ON customer.* TO
russ@192.168.1.79

In addition, I flushed the privileges, and I stopped and restarted the
database.

View Replies !
InnoDB, Can't Create Table
I had error message "Can't create table *.frm (errno:121)" when I was trying to create an innoDB table in MySQL Server 4.0.15. I know that the reason is the .frm files was deleted by some one which left data files. Does anybody know how to report and repair this sort of error.

View Replies !
Create Table Error 150
I am getting the error message

Script line: 84 Can't create table '.dwhf_umsatz.frm' (errno: 150)

during execution of the following script on a windows system and mysql 5.0: ...

View Replies !
#1005 - Can't Create Table
create table question_info (
question_no int,
author_id int,
subject char(30) not null,
topic char(30) not null,
question mediumblob not null,
question_type char(1) not null,
option1 mediumblob,
option2 mediumblob,
option3 mediumblob,
option4 mediumblob,
answer mediumblob,
level_of_difficulty char(1) not null,
marks int not null,
time_rqrd time not null,
primary key(question_no),
foreign key(author_id) references user(userid)
)

I have executed this query in linux but its giving
"#1005 - Can't create table '.question_bankquestion_info.frm' (errno: 150)"

error.....

View Replies !
Errors In CREATE TABLE
For some reason i can never get it right!!! I am making a blog and now entering the blog in the database Code:

CREATE TABLE blog( title CHAR(20) NOT NULL , date DATE, message NOT NULL);


View Replies !
Create Table Query
I just dump this script from another database so I could add the same create table query for different db, when I run the query I get the error.

mysql> CREATE TABLE SENT_MESSAGES (
-> INDNUMBER int(11) NOT NULL auto_increment,
-> CLIENT varchar(100) NOT NULL default '',
-> CODE varchar(100) NOT NULL default '',
-> TYPE varchar(100) NOT NULL default '',
-> WHEN timestamp(14) NOT NULL,
-> PRIMARY KEY (INDNUMBER)
-> ) TYPE=MyISAM;
ERROR 1064: You have an error in your SQL syntax near 'WHEN timestamp(14) NOT NULL,
PRIMARY KEY (INDNUMBER)
) TYPE=MyISAM' at line 6

View Replies !
Table Create Error
I just dump those table from mysql table, and re-run this sql code on different db name and it gives me the following error:

mysql> CREATE TABLE SENT_MESSAGES (
-> INDNUMBER int(11) NOT NULL auto_increment,
-> CLIENT varchar(100) NOT NULL default '',
-> CODE varchar(100) NOT NULL default '',
-> TYPE varchar(100) NOT NULL default '',
-> WHEN timestamp(14) NOT NULL,
-> PRIMARY KEY (INDNUMBER)
-> ) TYPE=MyISAM;
ERROR 1064: You have an error in your SQL syntax near 'WHEN timestamp(14) NOT NULL,
PRIMARY KEY (INDNUMBER)
) TYPE=MyISAM' at line 6

View Replies !
Create A Workschedule Table
Tips needed on how to create a workschedule table. Students will be entering their available work hours and class schedule in the same table. I would like to have Sunday through Sarurday as the columns and the hours from 6:00 a.m. to 11:00 p.m. as the rows. The hours will be in one hour increments (ex. 6:00 - 7:00, 7:00 - 8:00 and so on ).

View Replies !
Create A Table Without A Primary Key
I have a developer who was trying to create a table without a primary key, and he was having problems inserting data in via some c++ routines. When he added a primary key everything worked fine.
Any ideas why this might happen?
Why would you ever create a table without a primary key?

View Replies !
Can Not Create A Table (mysql 5.0.22)
I am using mysql 5.0.22 and I can not create a table. I end up getting a 1064 error. I can insert, delete, and update within the tables just fine.

I looked at the user permissions and I have assigned all priviledges to the user. I am using MySQL Administrator and MySQL Query Browser and I get the same problem in both. I even tried doing it manually within the Query Browser but its the same error.

I have just recently upgraded mysql from 4 to 5 and was wondering if there was a setting I needed to change so I can create tables.

View Replies !
Cannot Create Temporary Table
I cannot create a temporary table. What am I doing wrong?

CREATE TEMPORARY TABLE UMB.SRC_TMP
Select * from SRC_TMP limit 10;

Select count(*) from UMB.SRC_TMP;

table 'umb.src_tmp' doesn't exist.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved