create-table

CREATE TABLE permission denied in database 'tempdb'

送分小仙女□ 提交于 2019-12-03 22:56:07
First time I installed SQL Server Management Studio Express and Visual Studio 2005 on my system. Now I am trying to create table by using below script. But if once I execute I am facing error like CREATE TABLE permission denied in database 'tempdb'. Why it it? Can anyone help me how to resolve this ? USE [tempdb] GO SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Employee] ([FirstName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [LastName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] Thanks Raju My initial guess is you do not have

Column, parameter, or variable #10: Cannot find data type

吃可爱长大的小学妹 提交于 2019-12-03 22:34:20
I'm trying to create table from template code. This template code is working: CREATE TABLE [dbo].[Table1] ( [Field1] [int] NULL, [Field2] [float] NULL ) ON [PRIMARY] But if I put varchar(10): CREATE TABLE [dbo].[Table1] ( [Field1] [int] NULL, [Field2] [varchar(10)] NULL ) ON [PRIMARY] I get error: Msg 2715, Level 16, State 7, Line 1 Column, parameter, or variable #2: Cannot find data type varchar(10). The problem are brackets []. You have to put only varchar into brackets: [varchar](10) Code: CREATE TABLE [dbo].[Table1] ( [Field1] [int] NULL, [Field2] [varchar](10) NULL ) ON [PRIMARY] Or you

Why does all columns get created as string when I use OpenCSVSerde in Hive?

馋奶兔 提交于 2019-12-03 16:07:49
I am trying to create a table using the OpenCSVSerde and some integer and date columns. But the columns get converted to String. Is this an expected outcome? As a workaround, I do an explicit type-cast after this step (which makes the complete run slower) hive> create external table if not exists response(response_id int,lead_id int,creat_date date ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde' WITH SERDEPROPERTIES ('quoteChar' = '"', 'separatorChar' = '\,', 'serialization.encoding'='UTF-8', 'escapeChar' = '~') location '/prod/hive/db/response' TBLPROPERTIES ("serialization

Why is peewee including the 'id' column into the mysql select query?

一笑奈何 提交于 2019-12-03 12:10:35
问题 I am trying to learn how to use peewee with mysql. I have an existing database on a mysql server with an existing table. The table is currently empty (I am just testing right now). >>> db = MySQLDatabase('nhl', user='root', passwd='blahblah') >>> db.connect() >>> class schedule(Model): ... date = DateField() ... team = CharField() ... class Meta: ... database = db >>> test = schedule.select() >>> test <class '__main__.schedule'> SELECT t1.`id`, t1.`date`, t1.`team` FROM `nhl` AS t1 [] >>>

What does regclass signify in Postgresql

三世轮回 提交于 2019-12-03 08:08:34
问题 I have the following line in a CREATE TABLE statement: field1_id bigint DEFAULT nextval('table1_field1_id_seq'::regclass) NOT NULL, What does regclass signify in the above? Is it an absolute requirement to add ::regclass ? N.B: I had seen the Postgresql documentation link which tells about regclass , but couldn't understand it. 回答1: No, you do not need the cast to regclass when calling a function like nextval that accepts a regclass parameter, as there is an implict cast from text to regclass

MySQL - How to create a new table that is a join on primary key of two existing tables

纵饮孤独 提交于 2019-12-03 05:56:31
I have two existing tables, with different fields, except for Primary ID (a varchar, not an int). I want to create a third table which is essentially a merge of these two, such that for a given Primary Key I have all fields in one table. What's the bext way of doing this? Many thanks If you are sure you have one and exactly one row in both tables for a given primary ID, then this should work: SELECT tablea.field1, tablea.field2, tablea.field3, ... tablea.fieldn, <---- field list tableb.field1, tableb.field2, tableb.field3, ... tableb.fieldm <---- field list FROM tablea, tableb WHERE tablea

postgres: create table in database

*爱你&永不变心* 提交于 2019-12-03 04:20:17
I am trying to create a table in postgres, but it ends up in the wrong database. Here is what I do: in my sql script initially I create a user and a database, and then a table. Code will explain more: drop database if exists sinfonifry; drop role if exists sinfonifry; -- create the requested sinfonifry user create user sinfonifry createdb createuser password 'some_password'; -- create a sinfonifry database create database sinfonifry owner sinfonifry; DROP TABLE if exists sinf01_host; CREATE TABLE sinf01_host ( host_id bigserial NOT NULL, -- The primary key host_ip inet NOT NULL, -- The IP of

How to create mysql table with column timestamp default current_date?

夙愿已清 提交于 2019-12-03 03:03:57
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 NULL, `version` VARCHAR(500) NOT NULL, `platform` ENUM('w','l','m') NOT NULL, `date` TIMESTAMP NOT NULL DEFAULT CURRENT_DATE(), PRIMARY KEY (`id`), UNIQUE KEY `person` (`ip`,`date`) ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; but it is writting an error Query: CREATE TABLE `visitors` ( `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `ip`

create table in postgreSQL

我只是一个虾纸丫 提交于 2019-12-03 01:26:59
问题 I do not understand what is wrong with this query? Query tool does not want to create a table in PostgreSQL. CREATE TABLE article ( article_id bigint(20) NOT NULL auto_increment, article_name varchar(20) NOT NULL, article_desc text NOT NULL, date_added datetime default NULL, PRIMARY KEY (article_id) ); 回答1: First the bigint(20) not null auto_increment will not work, simply use bigserial primary key . Then datetime is timestamp in PostgreSQL. All in all: CREATE TABLE article ( article_id

Oracle schema user cannot create table in procedure

删除回忆录丶 提交于 2019-12-02 23:46:45
问题 I'm trying to create a temporary table in a procedure: PROCEDURE pr_create_tmp_bp_table(fp_id NUMBER) IS tbl_name CONSTANT VARCHAR2(20) := 'BP_TO_DELETE'; BEGIN -- sanity checks removed for readablity EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || tbl_name || ' ' || 'ON COMMIT PRESERVE ROWS AS ' || 'SELECT * FROM infop_stammdaten.bp'; END; If I copy the BEGIN.._END block to a SQL worksheet everything works fine. So I think the user has the right to create a temporary table. If I