I'm trying to create a table, and can't figure out how to assign two columns to be unique.. I know how to alter a table thats already created, but how do you do it in the create..
im after a create if not exist col1 TEXT, col2 TEXT, col3 TEXT unique(col1, col2)
^very rough basic but you get the idea
...
string createTable = "CREATE TABLE IF NOT EXISTS " + m_strDatabase + "_TimeLogs (logName VARCHAR(16), logTime INTEGER, logCountry TEXT, UNIQUE(logName)) TYPE=MyISAM;";
When this runs, no table is created.
No errors either.
Im using an ODBC connector.
the variable passes in the db name, so that the table created would be users_Time...
Hi,
I have a database "temp" with table "A". I created new database "temp2".
I want to copy table "A" from "temp" to a new table in "temp2" . I tried this statement but it says I have incorrect syntax, here is the statement:
CREATE TABLE B IN 'temp2'
AS (SELECT * FROM A IN 'temp');
Here is the error:
Msg 156, Level 15, State 1, Li...
Is there a shortcut in phpMyAdmin to SHOW CREATE TABLE for a table (i.e. a button I can click to get the full query, not the truncated one)?
Also, can I query multiple SHOW CREATE TABLEs simultaneously in phpMyAdmin? If I separate them, only the last one appears.
...
I get this error when trying to run this Oracle SQL script. Any help please?
Error messages
((29,21) expected token:; [ ) * + , - / = > DROP WHERE HAVING AND OR NOT ON JOIN FROM GROUP
((34,21) expected token:; [ ) * + , - / = > DROP WHERE HAVING AND OR NOT ON JOIN FROM GROUP
((39,21) expected token:; [ ) * + , - / = > DROP WHERE HAVI...
If some one does right click on a given Table in a Database using SQL Server management Studio from Microsoft and create script table to query window, it displays the create table code in the window. I notice something like the following
CREATE TABLE [dbo].[Login](
[UserId] [int] NOT NULL,
[LoginName] nvarchar COLLATE SQL_Latin...
I have a database in my production server and it works fine... What i did is took a dump of that DB and executed in my local system.. All the other tables are created except one table... So i manually inserted it,
CREATE TABLE `contact` (
`contactId` int(11) NOT NULL AUTO_INCREMENT,
`cRefId` int(20) DEFAULT '0',
`contactFirstName`...
My table is as follows:
CREATE TABLE IF NOT EXISTS PHONES (
number VARCHAR(10),
id INT,
type VARCHAR(10),
PRIMARY KEY (number),
FOREIGN KEY (id)
REFERENCES TECHNICIANS(id)
ON DELETE CASCADE
) ENGINE = INNODB;
I would like to specify for each id one primary contact number. I was thinking of adding a ...
With Rails/ActiveRecord 2.3.8 I'd like to do:
AnyModel.connection.create_table( 'temp_any_model', temporary: true, id: false, options: 'like any_model' )
But AR insists on adding "()" to the generated SQL even though the field list is blank since the table DDL is being cloned, thus resulting in e.g.:
ActiveRecord::StatementInvalid: M...
Is there a way in SQL Server to create a table with a primary key that auto-increments itself? I've been looking at the "UniqueIdentifier" type, but this doesn't seem to do what I expect.
Currently, I have something like this:
CREATE TABLE [dbo].[MyTable](
[Date] [datetime] NOT NULL,
[MyField1] [nchar](50) NOT NULL,
[M...
I'm working with sqlite and trying to create a table from another.
This works:
create table sources_tmp as select "literal" system,name,user from sources;
but it doesn't allow me to specify the type for the "literal".
I've tried this but doesn't work that way apparently:
create table sources_tmp as select "literal" system as $TYPE,...
I created this using MySQL WorkBench
CREATE TABLE IF NOT EXISTS `bakasura_new`.`cities` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(255) NOT NULL COMMENT 'City Name' ,
`short_name` VARCHAR(255) NOT NULL COMMENT 'Short Name' ,
`country_id` INT(11) UNSIGNED NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_cities...
I create the following table in H2:
CREATE TABLE TEST
(ID BIGINT NOT NULL PRIMARY KEY)
Then I look into INFORMATION_SCHEMA.TABLES table:
SELECT SQL
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'TEST'
Result:
CREATE CACHED TABLE TEST(
ID BIGINT NOT NULL
)
Then I look into INFORMATION_SCHEMA.CONSTRAINTS table:
SELECT SQ...