Questions tagged [create-table]

The statement that creates a table in SQL (`CREATE TABLE ...`).

The statement that creates a table in SQL (CREATE TABLE ...). Use this tag if your question refers to a problem that might have a relation with an SQL statement that involves a CREATE TABLE statement. Do not use this tag if you have no indication that the CREATE TABLE statement has no relation to the error you are asking about.

1935 questions
25
votes
5 answers

create SQL Server table based on a user defined type

I have my defined table type created with CREATE TYPE dbo.MyTableType AS TABLE ( Name varchar(10) NOT NULL, ValueDate date NOT NULL, TenorSize smallint NOT NULL, TenorUnit char(1) NOT NULL, Rate float …
gt6989b
  • 4,125
  • 8
  • 46
  • 64
24
votes
6 answers

#1064 -You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

I'm new to PHP and MySQL and ran into a little trouble with a learning project I'm working on. Whenever I try to create a table CREATE TABLE transactions( id int NOT NULL AUTO_INCREMENT, location varchar(50) NOT NULL, description varchar(50) NOT…
tsjr63
  • 349
  • 1
  • 2
  • 3
23
votes
5 answers

Is there any way for DBUnit to automatically create tables?

I just realized that DBUnit doesn't create tables by itself (see How do I test with DBUnit with plain JDBC and HSQLDB without facing a NoSuchTableException?). Is there any way for DBUnit to automatically create tables from a dataset or dtd? EDIT: …
neu242
  • 15,796
  • 20
  • 79
  • 114
20
votes
7 answers

C# - Create SQL Server table programmatically

I am trying to create a SQL Server table programmatically. Here is the code. using (SqlConnection con = new SqlConnection(conStr)) { try { // // Open the SqlConnection. // con.Open(); // //…
user2412672
  • 1,459
  • 3
  • 20
  • 36
20
votes
3 answers

Mysql: What is 'AUTO_INCREMENT=5' in a create table query?

I have a create table query in which there is a last clause which says AUTO_INCREMENT=5 Could someone explain what does that mean? below is the sample create table MySQL query CREATE TABLE IF NOT EXISTS `uploaderdata` ( `id` int(11) NOT NULL…
Padyster
  • 993
  • 3
  • 11
  • 21
20
votes
3 answers

Create new Table in ruby on rails

I try to create a new table in rails. Every example I find and try sadly does not work with me... so that's what I tried till now: (I use Ruby version 1.9 and Rails Version 3.2.13 making a new model in the terminal: rails generate model content…
Eumundi
  • 223
  • 1
  • 2
  • 6
19
votes
3 answers

sqlite3: creating table with no columns

I want to create table with no columns in sqlite3. It is possible in postgres database, but not in a sqlite3 one. Is there any way to achieve this, or is it simply not supported (maybe not in sql standard?) I have checked sqlite3 CREATE TABLE…
gruszczy
  • 40,948
  • 31
  • 128
  • 181
18
votes
3 answers

How to create mysql table with column timestamp default current_date?

I need to create mysql table with default value on column CURRENT_DATE() I try DROP TABLE IF EXISTS `visitors`; CREATE TABLE `visitors` ( `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `ip` VARCHAR(32) NOT NULL, `browser` VARCHAR(500) NOT…
maia bardavelidze
  • 383
  • 1
  • 3
  • 10
18
votes
3 answers

phpMyAdmin and SHOW CREATE TABLE

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…
waiwai933
  • 14,133
  • 21
  • 62
  • 86
18
votes
2 answers

How to copy structure of one table to another with foreign key constraints in psql?

Foreign key constraints are not copied when using create table table_name ( like source_table INCLUDING ALL)' in Postgres. How can I create a copy of an existing table including all foreign keys.
xxxxx
  • 1,918
  • 2
  • 17
  • 22
18
votes
2 answers

Can ActiveRecord create tables outside of a migration?

I am working on a non Rails web app, so no migrations script by default. The Sequel ORM lets me create tables easily in a script: #!/usr/bin/env ruby require 'rubygems' require 'sequel' ## Connect to the database DB =…
Morgan
  • 19,934
  • 8
  • 58
  • 84
18
votes
1 answer

postgresql syntax error when creating a table

Hey everyone I need some help with creating tables. I have the script below and it creates a few tables. When i try to run the script it give me this error: psql:script.sql:10: ERROR: syntax error at or near "Group" LINE 6: CREATE TABLE Group( Can…
alpal
  • 181
  • 1
  • 1
  • 3
18
votes
3 answers

How to create and populate a table in a single step as part of a CSV import operation?

I am looking for a quick-and-dirty way to import CSV files into SQL Server without having to create the table beforehand and define its columns. Each imported CSV would be imported into its own table. We are not concerned about data-type…
Tim
  • 8,669
  • 31
  • 105
  • 183
17
votes
4 answers

SQLite composite key (2 foreign keys) Link table

I've read the rather cool styled BNF grammar for the SQLite create table statement found here: http://www.sqlite.org/lang_createtable.html I was wondering how I'd go about creating a link table between these I have one table, lets say, houses, and…
Luke
  • 3,481
  • 6
  • 39
  • 63
17
votes
2 answers

android sqlite CREATE TABLE IF NOT EXISTS

Having a little problem with creating new tables. When I use the CREATE TABLE command my new tables form as they should, but when I exit the activity the app crashes and I get a TABLE ALREADY EXISTS in the logcat. If I use CREATE TABLE IF NOT EXISTS…
johnsonjp34
  • 3,139
  • 5
  • 22
  • 48