2015-12-13 37 views
0

我在運行sql數據庫時遇到了問題,我想創建一個類似於數據庫的youtube。我有這個錯誤。Sql開發人員錯誤,無效字符。創建Youtube數據庫

CREATE TABLE `Like` ( `video_id` int(5) NOT NULL DEFAULT '0', `customer_id` int(6) NOT NULL DEFAULT '0', `rating` int(1) NOT NULL DEFAULT '0', `date` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`video_id`,`customer_id`), KEY `date` (`date`), KEY `video_id` (`video_id`), KEY `customer_id` (`customer_id`), KEY `rating` (`rating`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 
Error report - 
SQL Error: ORA-00911: invalid character 
00911. 00000 - "invalid character"' 

*Cause: identifiers may not start with any ASCII character other than 
      letters and numbers. $#_ are also allowed after the first 
      character. Identifiers enclosed by doublequotes may contain 
      any character other than a doublequote. Alternative quotes 
      (q'#...#') cannot use spaces, tabs, or carriage returns as 
      delimiters. For all other contexts, consult the SQL Language 
      Reference Manual. 
*Action: 

CREATE TABLE `movies` ( `id` int(5) NOT NULL DEFAULT '0', `year` int(4) DEFAULT '0', `title` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; 

    CREATE TABLE `Channel` ( `movie_id` int(5) NOT NULL DEFAULT '0', `customer_id` int(6) NOT NULL DEFAULT '0', KEY `movie_id` (`movie_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; 

CREATE TABLE `qualifying` ( `customer_id` int(6) NOT NULL DEFAULT '0', `date` date NOT NULL DEFAULT '0000-00-00', `movie_id` int(5) NOT NULL DEFAULT '0', KEY `movie_id` (`movie_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; 

CREATE TABLE `Like` ( `video_id` int(5) NOT NULL DEFAULT '0', `customer_id` int(6) NOT NULL DEFAULT '0', `rating` int(1) NOT NULL DEFAULT '0', `date` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`video_id`,`customer_id`), KEY `date` (`date`), KEY `video_id` (`video_id`), KEY `customer_id` (`customer_id`), KEY `rating` (`rating`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; 
+0

相當於不使用'INT(1)'等使用'int'代替。 –

+0

您的標籤指示Oracle數據庫,但您發佈的腳本看起來像MySQL。這是什麼? – sstan

+0

@sstan其MySQL我認爲。 –

回答

1

你的主要問題是,你正在嘗試到Oracle數據庫(你都清楚地在Oracle數據庫上,因爲你所得到的ORA-00911錯誤)上運行MySQL的句法的SQL腳本。

要麼使用Oracle語法編寫腳本,要麼更改數據庫並使用MySQL。

0

從你錯誤消息腳本很顯然,你試圖在Oracle數據庫這就是爲什麼你得到錯誤運行Mysql表腳本。

這裏有你需要的表腳本wokr在Oracle數據庫一些變化

  • 更換back-ticksdouble quotes(")
  • Number(P)

更換int(N)數據類型實例

CREATE TABLE "like" 
  (  
     "video_id"   Number(10) NOT NULL DEFAULT '0',  
     "customer_id"Number(10) NOT NULL DEFAULT '0',  
     "rating"     Number(10) NOT NULL DEFAULT '0',  
     "date"       DATE NOT NULL DEFAULT '0000-00-00',  
    CONSTRAINT video_customers_pk PRIMARY KEY ("video_id", "customer_id") 
     KEY "date"("date"),  -- Not sure how to change this in oracle 
     KEY video_id("video_id"),  
     KEY customer_id("customer_id"),  
     KEY rating("rating")  
  )  

注:我不知道這KEY video_id("video_id")Oracle

相關問題